Module

std/ws/mod.ts>WebSocket

Deno standard library
Go to Latest
interface WebSocket
implements AsyncIterable<WebSocketEvent>
Deprecated
Deprecated

use Deno.upgradeWebSocket

import { type WebSocket } from "https://dotland.deno.dev/std@0.116.0/ws/mod.ts";

Properties

readonly
conn: Deno.Conn
readonly
isClosed: boolean

Methods

[[Symbol.asyncIterator]](): AsyncIterableIterator<WebSocketEvent>
send(data: WebSocketMessage): Promise<void>
ping(data?: WebSocketMessage): Promise<void>
close(): Promise<void>

Close connection after sending close frame to peer. This is canonical way of disconnection but it may hang because of peer's response delay. Default close code is 1000 (Normal Closure)

close(code: number): Promise<void>
close(code: number, reason: string): Promise<void>
closeForce(): void

Close connection forcely without sending close frame to peer. This is basically undesirable way of disconnection. Use carefully.