Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/services/socketManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export class SocketManager {
private registeredHandlers = new Map<string, Set<SocketEventHandler>>();

constructor(config: SocketConfig) {
const defaults = {
transports: ['websocket', 'polling'] as ('polling' | 'websocket')[],
const defaultOptions: NonNullable<SocketConfig['options']> = {
transports: ['websocket', 'polling'],
autoConnect: true,
Expand Down Expand Up @@ -122,8 +124,13 @@ export class SocketManager {
*/
emit(event: string, data?: unknown): boolean {
if (this.socket?.connected) {
this.socket.emit(event, data);
return true;
try {
this.socket.emit(event, data);
return true;
} catch (error) {
console.warn('Failed to emit event:', event, error);
return false;
}
}

if (!this.queueEnabled) {
Expand Down
Loading