fix(types,client,server): improve type safety and harden client/server message handling
This commit is contained in:
@@ -36,7 +36,7 @@ export class UniverseConnection {
|
||||
universeCache: UniverseCache,
|
||||
universeConnectionArg: UniverseConnection
|
||||
): Promise<UniverseConnection> {
|
||||
let connectionToReturn: UniverseConnection;
|
||||
let connectionToReturn: UniverseConnection | undefined;
|
||||
universeCache.connectionMap.forEach(async (existingConnection) => {
|
||||
if (existingConnection.socketConnection === universeConnectionArg.socketConnection) {
|
||||
connectionToReturn = await this.mergeUniverseConnections(
|
||||
@@ -63,7 +63,7 @@ export class UniverseConnection {
|
||||
universeRef,
|
||||
authenticationRequest.name
|
||||
);
|
||||
if (universeChannelToAuthenticateAgainst.passphrase === authenticationRequest.passphrase) {
|
||||
if (universeChannelToAuthenticateAgainst?.passphrase === authenticationRequest.passphrase) {
|
||||
universeConnectionArg.authenticatedChannels.push(universeChannelToAuthenticateAgainst);
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ export class UniverseConnection {
|
||||
public static findUniverseConnectionBySocketConnection(
|
||||
universeCache: UniverseCache,
|
||||
socketConnectionArg: plugins.smartsocket.SocketConnection
|
||||
): UniverseConnection {
|
||||
): UniverseConnection | undefined {
|
||||
const universeConnection = universeCache.connectionMap.findSync((universeConnectionArg) => {
|
||||
return universeConnectionArg.socketConnection === socketConnectionArg;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user