@jkob/ws
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

@jkob/ws

Example Configuration

const config = {
  port: 1350,
  host: "wss://example.websocket.server.com",
  protocol: "example-protocol",
};

Using on server side

import { getServer } from "@jkob/ws/dist/server";

const server = getServer(config);
await server.start();
await server.stop();
import { getClient } from "@jkob/ws/dist/server";
const client = await getClient(config, "scope");
await client.connect();
client.send("type", "message to clients");
client.close();

Using in web browser

import { getWebClient } from "@jkob/ws/dist/browser":
const client = getWebClient(config, "scope");
await client.connect();
client.send("type", "message to clients");
client.on("type", (message) => {
	console.log("received message", message);
});
client.close();

Readme

Keywords

none

Package Sidebar

Install

npm i @jkob/ws

Weekly Downloads

3

Version

2.2.0

License

MIT

Unpacked Size

4.53 kB

Total Files

9

Last publish

Collaborators

  • jkob