Skip to content

Latest commit

 

History

History
204 lines (111 loc) · 3.78 KB

Server.md

File metadata and controls

204 lines (111 loc) · 3.78 KB

Class: Server

Table of contents

Constructors

Events

Accessors

Methods

Constructors

constructor

new Server(pakettoInstance?, preallocateBytes?, ...transports)

Creates a new server.

Parameters

Name Type Description
pakettoInstance PakettoInstance The paketto instance to use. Defaults to a new instance.
preallocateBytes number The number of bytes to preallocate for the packet buffer. Defaults to 1MB (1024 * 1024).
...transports ITransport[] The transports to use. If none are provided, a WebSocketTransport with port 3000 will be used.

Defined in

Server.ts:80

Events

onConnect

Optional onConnect: (client: SocketClient) => void

Type declaration

▸ (client): void

Called when a client connects to the server.

Parameters
Name Type Description
client SocketClient The client that connected.
Returns

void

Defined in

Server.ts:69

Accessors

buffer

get buffer(): Uint8Array

Returns

Uint8Array

Defined in

Server.ts:35


clients

get clients(): Map<number, SocketClient>

Returns a list of clients. This is a copy of the internal list, so modifying it will not affect the server.

Returns

Map<number, SocketClient>

Defined in

Server.ts:60


nextConnectionId

get nextConnectionId(): number

Gets the next connection ID.

Returns

number

Defined in

Server.ts:31


paketto

get paketto(): PakettoInstance

Returns

PakettoInstance

Defined in

Server.ts:24


transports

get transports(): Set<ITransport>

Returns a list of transports. This is a copy of the internal list, so modifying it will not affect the server.

Returns

Set<ITransport>

Defined in

Server.ts:52

Methods

broadcast

broadcast(event, data): void

Broadcasts a message to all connected clients.

Parameters

Name Type Description
event unknown The event identifier.
data unknown The data to send.

Returns

void

Defined in

Server.ts:127


start

start(): void

Starts the server.

Returns

void

Defined in

Server.ts:102


stop

stop(): void

Stops the server.

Returns

void

Defined in

Server.ts:116