Creating only one WS connection to pusher from admin
Also: migration to Typescript 4.5 and µWebsockets 1.20.4
This commit is contained in:
parent
4875a8fed9
commit
4cff230256
8 changed files with 206 additions and 87 deletions
|
@ -3,6 +3,7 @@ import { uuid } from "uuidv4";
|
|||
import Jwt, { verify } from "jsonwebtoken";
|
||||
import { TokenInterface } from "../Controller/AuthenticateController";
|
||||
import { adminApi, AdminBannedData } from "../Services/AdminApi";
|
||||
import { InvalidTokenError } from "../Controller/InvalidTokenError";
|
||||
|
||||
export interface AuthTokenData {
|
||||
identifier: string; //will be a email if logged in or an uuid if anonymous
|
||||
|
@ -26,7 +27,12 @@ class JWTTokenManager {
|
|||
try {
|
||||
return Jwt.verify(token, SECRET_KEY, { ignoreExpiration }) as AuthTokenData;
|
||||
} catch (e) {
|
||||
throw { reason: tokenInvalidException, message: e.message };
|
||||
if (e instanceof Error) {
|
||||
// FIXME: we are loosing the stacktrace here.
|
||||
throw new InvalidTokenError(e.message);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,6 +132,12 @@ export class SocketManager implements ZoneEventListener {
|
|||
const message = new AdminPusherToBackMessage();
|
||||
message.setSubscribetoroom(roomId);
|
||||
|
||||
console.log(
|
||||
`Admin socket handle room ${roomId} connections for a client on ${Buffer.from(
|
||||
client.getRemoteAddressAsText()
|
||||
).toString()}`
|
||||
);
|
||||
|
||||
adminRoomStream.write(message);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue