Skip to main content
Module

x/ptereno/lib/models/ServerSocket.ts>ServerSocket

An efficient and fully compliant Pterodactyl API wrapper.
Latest
class ServerSocket
extends EventEmitter
import { ServerSocket } from "https://deno.land/x/ptereno@v1.0.1/lib/models/ServerSocket.ts";

Constructors

new
ServerSocket(
client: Client,
server: string,
options?: SocketOptions,
)

Establishes a websocket connection with the Pterodactyl daemon.

If no intents are passed, all intents will be used.

Properties

private
optional
intents: Array<SocketIntentType>
private
ws: WebSocket
endpoint: string
readonly
getState

Returns the state of the websocket.

token: string

Methods

private
getNewToken()

Retrieves a new token from the API.

private
onClose(code: number, reason?: string)

Fired when the websocket is closed.

private
onError(err: Error)

Fired when the websocket encounters an error.

private
onMessage(data: SocketEvent)

Fired when a message is received from the server.

private
onOpen()

Fired when the websocket opens.

private
onReconnect(retries: number)

Fired when the websocket attempts to reconnect.

private
send(payload: SocketEvent<any>)

Sends socket data through the websocket.

private
sendAuth(token?: string)

Authorizes the connection with the websocket.

If no token is passed, a new token will be automatically fetched.

private
sendIntents()

Sends intents through the websocket indicating what events the user chooses to capture.

close(code?: number, reason?: string)

Closes the socket connection.

Prepares a connection to the Pterodactyl daemon.

Closes the socket connection without sending a close frame.

Use this method with caution.

reconnect(code?: number, reason?: string)

Reconnects to the daemon and prepares a new connection.

interface ServerSocket
import { type ServerSocket } from "https://deno.land/x/ptereno@v1.0.1/lib/models/ServerSocket.ts";

Methods

on<K extends keyof ServerSocketEventMap>(event: K, callback: ServerSocketEventMap[K]): this
once<K extends keyof ServerSocketEventMap>(event: K, callback: ServerSocketEventMap[K]): this