Skip to content

Deno package to easily create a WebSocket server that runs over TLS.

License

Notifications You must be signed in to change notification settings

altafonte/simple-secure-websocket-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@altafonte/simple-secure-websocket-server

Package to easily create a WebSocket server that runs over TLS.

Quick Links

Usage

Server

import { createSimpleSecureWebsocketServer } from "https://deno.land/x/[email protected]/mod.ts";

const socketHandler = (socket: WebSocket) => {
  socket.onerror = (e) => console.error("socket error", e);
  socket.onopen = () => console.log("new socket connection", socket);
  socket.onclose = () => console.log("bye, socket connection", socket);
};

const server = createSimpleSecureWebsocketServer({
  socketHandler,
  port: 8888,
  certFile: "./certs/certfile.pem", // certfile path
  keyFile: "./certs/keyfile.pem", // keyfile path
});

server.listen();

Client

const ws = new WebSocket("wss://127.0.0.1:8888/websocket");
ws.addEventListener("open", () => console.log("open"));
ws.addEventListener("close", () => console.log("close"));
ws.addEventListener("message", e => console.log("message!", e));

About

Deno package to easily create a WebSocket server that runs over TLS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published