Optional
acceptWhether the server should accept new users. If set to false, only users joined via server.join(
When not provided, the server will accept new users.
Optional
httpThe http configuration that the Server should use.
Optional
path?: stringThe http path the Server should use for the websocket server.
When not provided, the websocket server will use the root path.
Optional
queryQuery string parameters that all connections must provide in their connection url.
For example: when it is set to { krmx: 'my-server-1-0-2' } a client should connect with 'ws:127.0.0.1:80/example?krmx=my-server-1-0-2'
Optional
server?: Server<typeof IncomingMessage, typeof ServerResponse>The http server that the Server should use.
When not provided, a new http server will be created.
When not provided, a new http server will be created and the WebSocket server will be on the root path.
Optional
isA predicate that determines what the server should consider to be a valid username.
A predicate that determines what the server should consider to be a valid username.
When not provided, the server will validate usernames using the following regex: /^[a-z0-9_-]{3,20}$/.
When not provided, the server will validate usernames using the following regex: /^[a-z0-9_-]{3,20}$/.
Optional
loggerThe logger that the Server should use.
When not provided, it will log (non debug) to the standard console.
Optional
metadataWhether metadata should be added to messages send over websocket connections.
If set to true, each message send or broadcast to users will include a 'metadata' field in the root of the json message including the timestamp it was sent and whether the message was a broadcast.
Example of a message that was sent when metadata is set to true: { type: "custom/message", payload: { value: 3 }, metadata: { isBroadcast: false, timestamp: "2023-04-07T19:17:11.432Z" }, }
When not provided, no metadata will be added to messages.
The properties with which to create the Server.