WS Client

A simple WebSocket client for Deno, inspired by pogsocket and v-websocket.

Usage

import { ... } from "https://deno.land/x/socket_client@VERSION/mod.ts";

Note Require --allow-read and --allow-net flags.

Example

import { WSClient, OpCode } from "https://deno.land/x/socket_client@VERSION/mod.ts";

const client = new WSClient({
  uri: "ws://localhost:80/"
});

client.onmessage = (_, message) => {
  if (message.opcode === OpCode.TextFrame) {
    console.log(new TextDecoder().decode(message.payload));
  }
};

await client.connect();
client.sendMessage("ping");

License

MIT License. See LICENSE