@jsprismarine/raknet
Version:
Basic RakNet implementation written in TypeScript
55 lines • 2.05 kB
TypeScript
import { EventEmitter } from 'events';
import { RemoteInfo } from 'node:dgram';
import { default as RakNetSession } from './Session';
import { default as Packet } from './protocol/Packet';
import { ServerName } from './utils/ServerName';
type Logger = {
info: Function;
warn: Function;
error: Function;
verbose: Function;
debug: Function;
silly: Function;
};
export default class ServerSocket extends EventEmitter {
private maxConnections;
private readonly onlineMode;
readonly serverName: ServerName;
private readonly logger;
private readonly socket;
private readonly guid;
private readonly sessions;
private ticker;
private readonly offlineHandler;
constructor(maxConnections: number, onlineMode: boolean, serverName: ServerName, logger: Logger);
start(address: string, port: number): void;
private handleMessage;
kill(): void;
/**
* Used to retrieve if we are overflowing the maximum
* connections we can allow, value given in the constructor.
* @returns {boolean} if we can hold new connections.
*/
allowIncomingConnections(): boolean;
/**
* Returns the maximum number of incoming connections.
* @returns {number} the maximum connections we can allow.
*/
getMaxConnections(): number;
/**
* Sets the maximum number of allowed incoming connections.
* @param {number} allowed - maximum number of connections.
*/
setMaxConnections(allowed: number): void;
addSession(rinfo: RemoteInfo, mtuSize: number, incomingGuid: bigint): void;
removeSession(session: RakNetSession, reason?: string): void;
getLogger(): Logger;
getSessions(): RakNetSession[];
getSessionByAddress(rinfo: RemoteInfo): RakNetSession | null;
getSessionByGUID(guid: bigint): RakNetSession | null;
getServerGuid(): bigint;
sendPacket<T extends Packet>(packet: T, rinfo: RemoteInfo): void;
sendBuffer(buffer: Buffer, rinfo: RemoteInfo): void;
}
export {};
//# sourceMappingURL=ServerSocket.d.ts.map