修复了有旧会话信息时,无法自动重置会话的bug
This commit is contained in:
@ -70,21 +70,6 @@ async function Request(req)
|
||||
return response;
|
||||
}
|
||||
|
||||
var SessionReadyEvent = new Event('SessionReady');
|
||||
(async () => {
|
||||
if(session_token==null||outhentication_key==null||operation_count==null){
|
||||
let tmp_channel=generateRandomString(10);
|
||||
let ret=await RawRequest('#OpenSession '+tmp_channel);
|
||||
operation_count=0;
|
||||
session_token=ret.split('\n')[1].split(' ')[0];
|
||||
outhentication_key=ret.split('\n')[1].split(' ')[1];
|
||||
localStorage.setItem("session_token", session_token);
|
||||
localStorage.setItem("outhentication_key", outhentication_key);
|
||||
localStorage.setItem("operation_count", operation_count);
|
||||
document.dispatchEvent(SessionReadyEvent);
|
||||
}
|
||||
})();
|
||||
|
||||
async function GetMyName()
|
||||
{
|
||||
session_token=localStorage.getItem("session_token");
|
||||
|
@ -195,8 +195,10 @@
|
||||
}
|
||||
}
|
||||
document.addEventListener('SessionReady', async () => {
|
||||
console.log("receive event session ready");
|
||||
await UpdateUserInfo();
|
||||
});
|
||||
</script>
|
||||
<script src="/sessioninit.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -106,6 +106,9 @@ app.get('/', (req, res) => {
|
||||
app.get('/communication.js', (req, res) => {
|
||||
res.sendFile(join(__dirname, 'communication.js'));
|
||||
});
|
||||
app.get('/sessioninit.js', (req, res) => {
|
||||
res.sendFile(join(__dirname, 'sessioninit.js'));
|
||||
});
|
||||
|
||||
io.on('connection', async (socket) => {
|
||||
console.log('a user connected');
|
||||
|
@ -257,5 +257,6 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script src="/sessioninit.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -269,5 +269,6 @@
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<script src="/sessioninit.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -261,5 +261,6 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script src="/sessioninit.js"></script>
|
||||
</body>
|
||||
</html>
|
15
frontend/Web/sessioninit.js
Normal file
15
frontend/Web/sessioninit.js
Normal file
@ -0,0 +1,15 @@
|
||||
var SessionReadyEvent = new Event('SessionReady');
|
||||
(async () => {
|
||||
if(session_token==null||outhentication_key==null||operation_count==null){
|
||||
let tmp_channel=generateRandomString(10);
|
||||
let ret=await RawRequest('#OpenSession '+tmp_channel);
|
||||
operation_count=0;
|
||||
session_token=ret.split('\n')[1].split(' ')[0];
|
||||
outhentication_key=ret.split('\n')[1].split(' ')[1];
|
||||
localStorage.setItem("session_token", session_token);
|
||||
localStorage.setItem("outhentication_key", outhentication_key);
|
||||
localStorage.setItem("operation_count", operation_count);
|
||||
}
|
||||
document.dispatchEvent(SessionReadyEvent);
|
||||
console.log("Sent event Session Ready");
|
||||
})();
|
Reference in New Issue
Block a user