Skip to content

Type Alias: SocketIOServiceEntrypointOptions ​

说明

本页由源码中的注释生成,内容为英文。

SocketIOServiceEntrypointOptions = InterfaceListeningOptions & object

The options of socketIOServiceEntrypoint; with interface, its own server listens on network interfaces instead of an address (see InterfaceListeningOptions).

Type Declaration ​

event? ​

optional event?: string

The socket.io event carrying the requests: socket.emit('message', {cmd: 'echo', …}, (response) => …).

Default ​

ts
'message'

host? ​

optional host?: string

The host or address of the adapter's own server; excludes interface.

Default ​

ts
all the interfaces

io? ​

optional io?: SocketIOServer

An existing socket.io server to serve the requests on, used as is: the adapter neither makes it listen nor closes it, and ignores server, port, host and options.

Default ​

ts
a socket.io server created by the adapter

listening? ​

optional listening?: (io, server, listeners?) => void | Promise<void>

Run once the adapter is ready, with the socket.io server and its HTTP server (undefined when io is given without server); with interface, the listeners of the interfaces too (the server itself does not listen then: its address() is null, the listeners give the port and the addresses). A failure fails the entrypoint start.

Parameters ​

io ​

SocketIOServer

server ​

Server | undefined

listeners? ​

IInterfaceListener[]

Returns ​

void | Promise<void>

middlewares? ​

optional middlewares?: MiddlewareDefinition[]

The middlewares of this adapter's actions, run after the entrypoint's global middlewares.

name? ​

optional name?: string

The adapter name, to tell apart several service adapters of one entrypoint.

namespace? ​

optional namespace?: string

The socket.io namespace receiving the requests.

Default ​

ts
'/'

options? ​

optional options?: Partial<ServerOptions>

The options of the socket.io server created by the adapter (path, cors, transports…).

port? ​

optional port?: number

The port of the adapter's own server (without server and io); 0 picks a random free port. The entrypoint fails to start when the port is in use.

Default ​

ts
3000

server? ​

optional server?: Server | (() => Server)

An HTTP server to attach the socket.io server to (such as the one of expressHTTPEntrypoint, given to its before hook), or a function returning it when the adapter starts. The adapter then does not listen itself, and when it stops it disconnects the sockets but leaves the HTTP server to its owner.

Default ​

a server of its own, listening on port

Released under the MIT License.