mirror of
https://github.com/nvms/prsm.git
synced 2025-12-16 08:00:53 +00:00
allow typing on the callback return value for registerCommand
This commit is contained in:
parent
8ef12272be
commit
8dbc214e6f
Binary file not shown.
@ -130,7 +130,9 @@ export type KeepAliveServerOptions = ServerOptions & {
|
||||
export class KeepAliveServer extends WebSocketServer {
|
||||
connections: { [id: string]: Connection } = {};
|
||||
remoteAddressToConnections: { [address: string]: Connection[] } = {};
|
||||
commands: { [command: string]: (context: WSContext<any>) => Promise<void> } = {};
|
||||
commands: {
|
||||
[command: string]: (context: WSContext<any>) => Promise<any> | any;
|
||||
} = {};
|
||||
globalMiddlewares: SocketMiddleware[] = [];
|
||||
middlewares: { [key: string]: SocketMiddleware[] } = {};
|
||||
rooms: { [roomName: string]: Set<string> } = {};
|
||||
@ -330,9 +332,9 @@ export class KeepAliveServer extends WebSocketServer {
|
||||
this.rooms[roomName] = new Set();
|
||||
}
|
||||
|
||||
registerCommand(
|
||||
registerCommand<T>(
|
||||
command: string,
|
||||
callback: SocketMiddleware,
|
||||
callback: (context: WSContext<any>) => Promise<T> | T,
|
||||
middlewares: SocketMiddleware[] = [],
|
||||
) {
|
||||
this.commands[command] = callback;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user