Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/snel/imports/wocket.ts>Server

A Cybernetical framework for svelte applications in deno
Latest
class Server
extends EventEmitter
import { Server } from "https://deno.land/x/snel@v0.7.1/imports/wocket.ts";

The SocketServer class is responsible for creating a users socket server. Similar to how Drash.Http.Server creates a server instance.

Constructors

new
Server(transmitterOptions?: ITransmitterOptions)

Construct an object of this class.

Properties

deno_server: DenoServer | null

A property to hold the Deno server. This property is set in this.run() like so:

this.deno_server = serve();
hostname: string

A property to hold the hostname this server listens on.

port: number

A property to hold the port this server listens on.

transmitter: Transmitter

A property to hold the transmitter. The transmitter is in charge of transmitting data throughout the server-client lifecycle.

Methods

protected
acceptWebSockets()

Accept incoming web sockets as clients.

protected
handleMessageAsBinary(client: Client, message: Uint8Array)

Handle a binary message sent by the socket client.

protected
handleMessageAsJsonString(client: Client, message: string): Promise<void>

Handle a message in the format of a JSON string.

protected
handleMessageAsString(client: Client, message: string): Promise<void>

Handle a string message sent by the socket client.

close(): Promise<void>

Close the server.

run(options: HTTPOptions): DenoServer

Handles websocket connection. After a successful connection, the client will be added to EventEmitter.clients and the server will start listening to events.

runTLS(options: HTTPSOptions): DenoServer

Handles websocket secure connection. After a successful connection, the client will be added to EventEmitter.clients and the server will start listening to events.