Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more

PogSocket

A functional deno websocket client!

Usage

Connecting to Echo Server

import { connectPogSocket, readSocket, sendMessage } from "https://deno.land/x/pogsocket/mod.ts";

const socket = await connectPogSocket("ws://localhost:3030");
setInterval(() => sendMessage(socket, "hello me!"), 2000);

for await (const event of readSocket(socket)) {
    if (event.type === "message") {
        console.log(event.message);
    }
}

Acknowledgements

  • /websocket (and parts of /pogsocket) were originally written by the Deno Authors, this couldnโ€™t have been done without them :)

melike2d