🎉 support client message push

This commit is contained in:
Song
2021-06-13 17:52:41 +08:00
parent fcb48d4ff0
commit 018d252e5d
11 changed files with 485 additions and 6 deletions
+16
View File
@@ -84,10 +84,26 @@ function checkAccessToken(prefix, token) {
}
}
function checkPrefix(prefix) {
let user = tokenStore.get(prefix);
return user !== undefined;
}
function registerWebSocket(prefix, token, ws) {
let user = tokenStore.get(prefix);
if (user && user.accessToken !== '' && user.accessToken === token) {
updateTokenStore(prefix, 'ws', ws);
} else {
ws.terminate();
}
}
module.exports = {
initializeTokenStore,
updateTokenStore,
getUserDefaultMethod,
tokenStore,
checkAccessToken,
checkPrefix,
registerWebSocket,
};