refactor web socket layer

This commit is contained in:
seavor 2026-04-14 14:39:46 -05:00
parent 19f5eefdd2
commit 141f0e59f5
124 changed files with 927 additions and 853 deletions

View file

@ -3,9 +3,6 @@ vi.mock('websocket', () => ({
connect: vi.fn(),
disconnect: vi.fn(),
},
webClient: {
connectionAttemptMade: false,
},
}));
vi.mock('generated/proto/serverinfo_user_pb', () => ({
@ -15,7 +12,7 @@ vi.mock('generated/proto/serverinfo_user_pb', () => ({
}));
import { AuthenticationService } from './AuthenticationService';
import { SessionCommands, webClient } from 'websocket';
import { SessionCommands } from 'websocket';
import { StatusEnum, WebSocketConnectOptions, WebSocketConnectReason } from 'types';
const testOptions: WebSocketConnectOptions = { host: 'localhost', port: '4748', userName: 'user', password: 'pw' };
@ -124,16 +121,4 @@ describe('AuthenticationService', () => {
expect(AuthenticationService.isAdmin()).toBeUndefined();
});
});
describe('connectionAttemptMade', () => {
it('returns webClient.connectionAttemptMade when false', () => {
(webClient as any).connectionAttemptMade = false;
expect(AuthenticationService.connectionAttemptMade()).toBe(false);
});
it('returns webClient.connectionAttemptMade when true', () => {
(webClient as any).connectionAttemptMade = true;
expect(AuthenticationService.connectionAttemptMade()).toBe(true);
});
});
});

View file

@ -1,5 +1,5 @@
import { StatusEnum, User, WebSocketConnectReason, WebSocketConnectOptions } from 'types';
import { SessionCommands, webClient } from 'websocket';
import { SessionCommands } from 'websocket';
import { ServerInfo_User_UserLevelFlag } from 'generated/proto/serverinfo_user_pb';
export class AuthenticationService {
@ -48,8 +48,4 @@ export class AuthenticationService {
static isAdmin() {
}
static connectionAttemptMade() {
return webClient.connectionAttemptMade;
}
}