API reference / @jsprismarine/raknet / WorkerServerSocket
Class: WorkerServerSocket
Defined in: raknet/src/WorkerServerSocket.ts:80
A server RakNet peer whose UDP socket, session reliability, and timers live in one worker. Frames cross the thread boundary through bounded shared-memory rings and are delivered to listeners only when pollInbound is called at the start of a game tick.
Extends
EventEmitter
Implements
Constructors
Constructor
new WorkerServerSocket(
maxConnections,_onlineMode,serverName,logger,socketBufferOptions?,ringCapacity?,sharedPort?):WorkerServerSocket
Defined in: raknet/src/WorkerServerSocket.ts:107
Parameters
maxConnections
number
Maximum concurrent RakNet sessions.
_onlineMode
boolean
Accepted for compatibility; RakNet has no online-mode branch.
serverName
The main-thread server-list state mirrored to the worker.
logger
Receives the worker's RakNet log messages.
socketBufferOptions?
SocketBufferOptions = {}
UDP socket buffers requested by the worker.
ringCapacity?
number = DEFAULT_RING_CAPACITY
Byte capacity of each bounded shared-memory ring.
sharedPort?
A port the worker reads through rings instead of a socket of its own.
Returns
WorkerServerSocket
Overrides
EventEmitter.constructor
Properties
serverName
readonlyserverName:ServerName
Defined in: raknet/src/WorkerServerSocket.ts:110
The main-thread server-list state mirrored to the worker.
Implementation of
Methods
allowIncomingConnections()
allowIncomingConnections():
boolean
Defined in: raknet/src/WorkerServerSocket.ts:243
Whether the main-thread view has room for another completed connection.
Returns
boolean
Implementation of
RakNetListenerLike.allowIncomingConnections
getLogger()
getLogger():
Logger
Defined in: raknet/src/WorkerServerSocket.ts:283
The logger also satisfies the RakNet peer used by proxy sessions.
Returns
Implementation of
getMaxConnections()
getMaxConnections():
number
Defined in: raknet/src/WorkerServerSocket.ts:248
Returns the connection limit.
Returns
number
Implementation of
RakNetListenerLike.getMaxConnections
getMetrics()
getMetrics():
object
Defined in: raknet/src/WorkerServerSocket.ts:319
Queue and reliability measurements shared by the worker.
Returns
object
inbound
inbound:
object
inbound.capacity
capacity:
number
inbound.fullWrites
fullWrites:
number
inbound.highWatermarkBytes
highWatermarkBytes:
number
inbound.queuedBytes
queuedBytes:
number
maxRoundTripMs
maxRoundTripMs:
number
outbound
outbound:
object
outbound.capacity
capacity:
number
outbound.fullWrites
fullWrites:
number
outbound.highWatermarkBytes
highWatermarkBytes:
number
outbound.queuedBytes
queuedBytes:
number
retransmissions
retransmissions:
number
roundTripSamples
roundTripSamples:
number
getServerGuid()
getServerGuid():
bigint
Defined in: raknet/src/WorkerServerSocket.ts:278
The GUID used in unconnected replies.
Returns
bigint
Implementation of
RakNetListenerLike.getServerGuid
getSessionByAddress()
getSessionByAddress(
rinfo):RakNetSession|null
Defined in: raknet/src/WorkerServerSocket.ts:264
Finds a completed session by remote address.
Parameters
rinfo
RemoteInfo
Returns
RakNetSession | null
Implementation of
RakNetListenerLike.getSessionByAddress
getSessionByGUID()
getSessionByGUID(
guid):RakNetSession|null
Defined in: raknet/src/WorkerServerSocket.ts:270
Finds a completed session by client GUID.
Parameters
guid
bigint
Returns
RakNetSession | null
Implementation of
RakNetListenerLike.getSessionByGUID
getSessions()
getSessions():
RakNetSession[]
Defined in: raknet/src/WorkerServerSocket.ts:259
Sessions whose connected handshake has reached the game-thread handoff point.
Returns
Implementation of
RakNetListenerLike.getSessions
getWorkerCpuUsage()
getWorkerCpuUsage():
Promise<CpuUsage>
Defined in: raknet/src/WorkerServerSocket.ts:336
CPU time consumed by the network worker since it started.
Returns
Promise<CpuUsage>
kill()
kill():
void
Defined in: raknet/src/WorkerServerSocket.ts:226
Stops accepting traffic and asks the worker to close its socket.
Returns
void
Implementation of
pollInbound()
pollInbound():
number
Defined in: raknet/src/WorkerServerSocket.ts:214
Delivers up to MAX_RECORDS_PER_TICK worker events in their shared-ring order.
Returns
number
The number of events delivered.
queueDisconnect()
queueDisconnect(
sessionId,reason,immediate):void
Defined in: raknet/src/WorkerServerSocket.ts:353
Sends a disconnect request to the worker in session order.
Parameters
sessionId
number
reason
string
immediate
boolean
Returns
void
queueFrame()
queueFrame(
sessionId,frame,priority):void
Defined in: raknet/src/WorkerServerSocket.ts:342
Adds an outgoing frame command without blocking the game thread.
Parameters
sessionId
number
frame
priority
Returns
void
removeSession()
removeSession(
session,reason?):void
Defined in: raknet/src/WorkerServerSocket.ts:309
Removes a main-thread proxy when its owning application explicitly asks.
Parameters
session
reason?
string
Returns
void
Implementation of
RakNetListenerLike.removeSession
sendBuffer()
sendBuffer(
buffer,rinfo):void
Defined in: raknet/src/WorkerServerSocket.ts:298
Sends a raw UDP datagram through the worker's socket.
Parameters
buffer
Buffer
rinfo
RemoteInfo
Returns
void
Implementation of
sendPacket()
sendPacket<
T>(packet,rinfo):void
Defined in: raknet/src/WorkerServerSocket.ts:292
Sends a raw RakNet packet through the worker's socket.
Type Parameters
T
T extends Packet
Parameters
packet
T
The packet to encode.
rinfo
RemoteInfo
The remote address.
Returns
void
Implementation of
setMaxConnections()
setMaxConnections(
allowed):void
Defined in: raknet/src/WorkerServerSocket.ts:253
Changes the worker's connection limit.
Parameters
allowed
number
Returns
void
Implementation of
RakNetListenerLike.setMaxConnections
start()
start(
address,port):void
Defined in: raknet/src/WorkerServerSocket.ts:141
Starts the worker and binds its UDP socket.
Parameters
address
string
port
number
Returns
void
Implementation of
waitUntilReady()
waitUntilReady():
Promise<void>
Defined in: raknet/src/WorkerServerSocket.ts:205
Resolves when the worker has bound the UDP socket.
Returns
Promise<void>