open-index/open-npm huggingface dataset:
npm package: @jkob/ws
Description: Studencik web socket server
Author: Jakub Wiśniewski
Latest version: 2.2.0

# @jkob/ws

## Example Configuration

```js
const config = {
  port: 1350,
  host: "wss://example.websocket.server.com",
  protocol: "example-protocol",
};
```

## Using on server side

```js
import { getServer } from "@jkob/ws/dist/server";

const server = getServer(config);
await server.start();
await server.stop();
```

```js
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

```js
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();
```