class WsAdapter extends AbstractWsAdapter {
constructor(appOrHttpServer?: any, options?: WsAdapterOptions)
protected logger: Logger
protected httpServersRegistry: Map<HttpServerRegistryKey, HttpServerRegistryEntry>
protected wsServersRegistry: Map<WsServerRegistryKey, WsServerRegistryEntry>
protected messageParser: WsMessageParser
create(port: number, options?: Record<string, any> & { namespace?: string; server?: any; path?: string; })
bindMessageHandlers(client: any, handlers: MessageMappingProperties[], transform: (data: any) => Observable<any>)
bindMessageHandler(buffer: any, handlersMap: Map<string, MessageMappingProperties>, transform: (data: any) => Observable<any>): Observable<any>
bindErrorHandler(server: any)
bindClientDisconnect(client: any, callback: Function)
close(server: any)
dispose()
setMessageParser(parser: WsMessageParser)
protected ensureHttpServerExists(port: number, httpServer: any = http.createServer())
protected addWsServerToRegistry<T extends Record<'path', string> = any>(wsServer: T, port: number, path: string)
}
Constructor
constructor(appOrHttpServer?: any, options?: WsAdapterOptions)
Parameters
| Option |
Type |
Description |
appOrHttpServer
|
any |
Optional. Default is undefined.
|
options
|
WsAdapterOptions |
Optional. Default is undefined.
|
|
Properties
| Property |
Description |
protected logger: Logger
|
Read-only.
|
protected httpServersRegistry: Map<HttpServerRegistryKey, HttpServerRegistryEntry>
|
Read-only.
|
protected wsServersRegistry: Map<WsServerRegistryKey, WsServerRegistryEntry>
|
Read-only.
|
protected messageParser: WsMessageParser
|
|
Methods
create()
|
create(port: number, options?: Record<string, any> & { namespace?: string; server?: any; path?: string; })
Parameters
| Option |
Type |
Description |
port
|
number |
|
options
|
Record & { namespace?: string; server?: any; path?: string; } |
Optional. Default is undefined.
|
|
bindMessageHandlers()
|
bindMessageHandlers(client: any, handlers: MessageMappingProperties[], transform: (data: any) => Observable<any>)
Parameters
|
bindMessageHandler()
|
bindMessageHandler(buffer: any, handlersMap: Map<string, MessageMappingProperties>, transform: (data: any) => Observable<any>): Observable<any>
Parameters
| Option |
Type |
Description |
buffer
|
any |
|
handlersMap
|
Map |
|
transform
|
(data: any) => Observable |
|
Returns
Observable<any>
|
bindErrorHandler()
|
bindErrorHandler(server: any)
Parameters
| Option |
Type |
Description |
server
|
any |
|
|
bindClientDisconnect()
|
bindClientDisconnect(client: any, callback: Function)
Parameters
| Option |
Type |
Description |
client
|
any |
|
callback
|
Function |
|
|
close()
|
close(server: any)
Parameters
| Option |
Type |
Description |
server
|
any |
|
|
dispose()
|
dispose()
Parameters
There are no parameters.
|
setMessageParser()
|
setMessageParser(parser: WsMessageParser)
Parameters
| Option |
Type |
Description |
parser
|
WsMessageParser |
|
|
ensureHttpServerExists()
|
protected ensureHttpServerExists(port: number, httpServer: any = http.createServer())
Parameters
| Option |
Type |
Description |
port
|
number |
|
httpServer
|
any |
Optional. Default is http.createServer().
|
|
addWsServerToRegistry()
|
protected addWsServerToRegistry<T extends Record<'path', string> = any>(wsServer: T, port: number, path: string)
Parameters
| Option |
Type |
Description |
wsServer
|
T |
|
port
|
number |
|
path
|
string |
|
|