{"id":23099182,"url":"https://github.com/giovannicalo/node-wrtc-ws-api-server","last_synced_at":"2026-04-18T04:02:22.065Z","repository":{"id":89746279,"uuid":"561053687","full_name":"giovannicalo/node-wrtc-ws-api-server","owner":"giovannicalo","description":"Node WebRTC WebSocket Signaling API Server","archived":false,"fork":false,"pushed_at":"2025-05-02T00:48:18.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-07T14:11:27.088Z","etag":null,"topics":["api","server","signaling","webrtc","websocket"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giovannicalo.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-02T20:59:03.000Z","updated_at":"2025-05-02T00:48:23.000Z","dependencies_parsed_at":"2024-01-20T16:26:46.350Z","dependency_job_id":"4d93467c-196b-4e4c-9780-72773d8e9195","html_url":"https://github.com/giovannicalo/node-wrtc-ws-api-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/giovannicalo/node-wrtc-ws-api-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovannicalo%2Fnode-wrtc-ws-api-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovannicalo%2Fnode-wrtc-ws-api-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovannicalo%2Fnode-wrtc-ws-api-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovannicalo%2Fnode-wrtc-ws-api-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giovannicalo","download_url":"https://codeload.github.com/giovannicalo/node-wrtc-ws-api-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giovannicalo%2Fnode-wrtc-ws-api-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31955919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","server","signaling","webrtc","websocket"],"created_at":"2024-12-16T23:18:30.974Z","updated_at":"2026-04-18T04:02:22.046Z","avatar_url":"https://github.com/giovannicalo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node WebRTC WebSocket Signaling API Server\n\n[![Build Status](https://github.com/giovannicalo/node-wrtc-ws-api-server/actions/workflows/build.yml/badge.svg)](https://github.com/giovannicalo/node-wrtc-ws-api-server/actions/workflows/build.yml)\n[![Coverage Status](https://coveralls.io/repos/github/giovannicalo/node-wrtc-ws-api-server/badge.svg?branch=master)](https://coveralls.io/github/giovannicalo/node-wrtc-ws-api-server?branch=master)\n\n## Installation\n\n```bash\nnpm install giovannicalo/node-wrtc-ws-api-server\n```\n\n\u003e Not yet published to NPM. This will install it from GitHub.\n\n## Usage\n\n```javascript\nconst Server = require(\"wrtc-ws-api-server\");\n\nnew Server(8080);\n```\n\n## API\n\n### `new Server(port: number, options?: Options)`\n\nStarts a WebSocket server listening on `port`.\n\nOptions are:\n\n* `authenticate?(data: JsonSerializable): boolean | Promise\u003cboolean\u003e`: a function to authenticate clients, which must return `true` if valid and `false` if not, defaults to `undefined`.\n* `heartbeatGracePeriod?: number`: how long to keep unresponsive clients alive, in milliseconds, should be greater than `heartbeatInterval`, defaults to `15000`.\n* `heartbeatInterval?: number`: how often to send `ping` events to clients, in milliseconds, should be less than `heartbeatGracePeriod`, defaults to `5000`.\n* `log?(level: \"error\" | \"info\" | \"warning\", message: string): void`: a logging function that will be called when certain events occur, defaults to `undefined`.\n* `socketOptions?: WebSocket.ServerOptions`: custom [options](https://github.com/websockets/ws/blob/master/doc/ws.md#class-websocketserver) to pass to the `WebSocketServer` constructor, except `port`.\n\n#### `authenticate?: (data: JsonSerializable) =\u003e boolean | Promise\u003cboolean\u003e`\n\nThe `authenticate` function passed to the `Server` constructor.\n\n#### `clients: Map\u003cstring, Client\u003e`\n\nA `Map` of `Client` objects, one for each client connected to the server.\n\n#### `close(): void`\n\nShuts down the server.\n\n#### `heartbeatGracePeriod: number`\n\nThe value of `heartbeatGracePeriod`, passed to the `Server` constructor.\n\n#### `heartbeatInterval: number`\n\nThe value of `heartbeatInterval`, passed to the `Server` constructor.\n\n#### `log?: (level: \"error\" | \"info\" | \"warning\", message: string) =\u003e void`\n\nThe `log` function passed to the `Server` constructor.\n\n#### `socket: WebSocketServer`\n\nThe [`WebSocketServer`](https://github.com/websockets/ws/blob/master/doc/ws.md#class-websocketserver) instance used by the `Server`.\n\n### `Client`\n\nEach of the clients connected to the `Server`.\n\nClients cannot be created manually, but they can be accessed via `Server.clients`.\n\n#### `address: string`\n\nThe `Client`'s IP address.\n\n#### `addClient(client: Client): void`\n\nAssigns a `client` `Client` to the current `Client`. Only makes sense for `worker` `Client`s. It should not be used manually.\n\n#### `chooseWorker(): void`\n\nForces the `Client` to choose a `worker` `Client`. Only makes sense for `client` `Client`s. It should not be used manually.\n\n#### `clients: Map\u003cstring, Client\u003e`\n\nA `Map` of `client` `Client`s assigned to the current `Client`. Only makes sense for `worker` `Client`s.\n\n#### `close(): void`\n\nCloses the `Client`'s connection.\n\n#### `firstSeen: number`\n\nThe time at which the `Client` connected.\n\n#### `id: string`\n\nThe `Client`'s ID.\n\n#### `lastSeen: number`\n\nThe time at which the `Client` last sent a message (`pong` or otherwise).\n\n#### `latency: number`\n\nThe `Client`'s latency, in milliseconds, sampled every `heartbeatInterval` milliseconds using `ping` events.\n\n#### `removeClient(client: Client): void`\n\nRemoves a `client` `Client` from the current `Client`. Only makes sense for `worker` `Client`s. It should not be used manually.\n\n#### `removeWorker(): void`\n\nRemoves the `worker` `Client` assigned to the current `Client`. Only makes sense for `client` `Client`s. It should not be used manually.\n\n#### `role: \"client\" | \"worker\"`\n\nThe `Client`'s role.\n\n#### `send(message: JsonSerializable): void`\n\nSends a `message` to the client.\n\n#### `worker: Client | null`\n\nThe `worker` `Client` used by the current `Client`. Only makes sense for `client` `Client`s.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiovannicalo%2Fnode-wrtc-ws-api-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiovannicalo%2Fnode-wrtc-ws-api-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiovannicalo%2Fnode-wrtc-ws-api-server/lists"}