diff options
author | bobzel <zzzman@gmail.com> | 2024-04-05 01:01:06 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-04-05 01:01:06 -0400 |
commit | b53ebc62e877adeeafe163282a9031a3a0dae611 (patch) | |
tree | c5de6d7ca7f5fdf4b43d790d88c867519cc6add6 /src/Utils.ts | |
parent | 5a213d6e132a77a018e08c9feb292644bc0ac385 (diff) |
more fixes to socket.io and socket.io-client includes
Diffstat (limited to 'src/Utils.ts')
-rw-r--r-- | src/Utils.ts | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/Utils.ts b/src/Utils.ts index a48fb2bc2..291d7c799 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -1,7 +1,7 @@ import * as Color from 'color'; import { ColorResult } from 'react-color'; import * as rp from 'request-promise'; -import { Socket } from 'socket.io-client'; +import { Socket } from 'socket.io'; import * as uuid from 'uuid'; import { DocumentType } from './client/documents/DocumentTypes'; import { Colors } from './client/views/global/globalEnums'; @@ -382,7 +382,7 @@ export namespace Utils { export const loggingEnabled: Boolean = false; export const logFilter: number | undefined = undefined; - function log(prefix: string, messageName: string, message: any, receiving: boolean) { + export function log(prefix: string, messageName: string, message: any, receiving: boolean) { if (!loggingEnabled) { return; } @@ -395,7 +395,7 @@ export namespace Utils { console.log(`${prefix}: ${idString}, ${receiving ? 'receiving' : 'sending'} ${messageName} with data ${JSON.stringify(message)} `); } - function loggingCallback(prefix: string, func: (args: any) => any, messageName: string) { + export function loggingCallback(prefix: string, func: (args: any) => any, messageName: string) { return (args: any) => { log(prefix, messageName, args, true); func(args); @@ -407,17 +407,6 @@ export namespace Utils { socket.emit(message.Message, args); } - export function EmitCallback<T>(socket: Socket, message: Message<T>, args: T): Promise<any>; - export function EmitCallback<T>(socket: Socket, message: Message<T>, args: T, fn: (args: any) => any): void; - export function EmitCallback<T>(socket: Socket, message: Message<T>, args: T, fn?: (args: any) => any): void | Promise<any> { - log('Emit', message.Name, args, false); - if (fn) { - socket.emit(message.Message, args, loggingCallback('Receiving', fn, message.Name)); - } else { - return new Promise<any>(res => socket.emit(message.Message, args, loggingCallback('Receiving', res, message.Name))); - } - } - export function AddServerHandler<T>(socket: Socket, message: Message<T>, handler: (args: T) => any) { socket.on(message.Message, loggingCallback('Incoming', handler, message.Name)); } |