{"id":22134221,"url":"https://github.com/ivoputzer/wss","last_synced_at":"2026-01-11T17:54:56.999Z","repository":{"id":14587778,"uuid":"17304412","full_name":"ivoputzer/wss","owner":"ivoputzer","description":"wrapper built upon ws module that provides standard server api only.","archived":false,"fork":false,"pushed_at":"2018-07-06T23:14:42.000Z","size":76,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-08T11:47:13.929Z","etag":null,"topics":["javascript","nodejs","websocket","websocket-server","ws","wss"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivoputzer.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-01T00:45:05.000Z","updated_at":"2024-11-17T09:16:52.000Z","dependencies_parsed_at":"2022-08-26T22:11:00.881Z","dependency_job_id":null,"html_url":"https://github.com/ivoputzer/wss","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivoputzer%2Fwss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivoputzer%2Fwss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivoputzer%2Fwss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivoputzer%2Fwss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivoputzer","download_url":"https://codeload.github.com/ivoputzer/wss/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246857785,"owners_count":20845194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["javascript","nodejs","websocket","websocket-server","ws","wss"],"created_at":"2024-12-01T19:10:09.443Z","updated_at":"2026-01-11T17:54:56.967Z","avatar_url":"https://github.com/ivoputzer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"wss\n===\nwrapper built upon [ws](https://www.npmjs.org/package/ws) module that provides standard server api only.\n\n[![travis](https://img.shields.io/travis/ivoputzer/wss.svg?style=for-the-badge)](https://travis-ci.org/ivoputzer/wss)\n[![dependencies](https://img.shields.io/badge/dependencies-1-blue.svg?style=for-the-badge\u0026colorB=44CC11)](package.json)\n[![linter](https://img.shields.io/badge/coding%20style-standard-brightgreen.svg?style=for-the-badge)](http://standardjs.com/)\n[![coverage](https://img.shields.io/coveralls/ivoputzer/wss.svg?style=for-the-badge)](https://coveralls.io/github/ivoputzer/wss?branch=master)\n\n[![node](https://img.shields.io/badge/node-6%2B-blue.svg?style=for-the-badge)](https://nodejs.org/docs/v6.0.0/api)\n[![version](https://img.shields.io/npm/v/wss.svg?style=for-the-badge\u0026colorB=007EC6)](https://www.npmjs.com/package/wss)\n[![minzip](https://img.shields.io/bundlephobia/minzip/wss.svg?style=for-the-badge)](https://www.npmjs.com/package/wss)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge\u0026colorB=007EC6)](https://spdx.org/licenses/MIT)\n\n#### usage with server creation\n\n```javascript\nconst {createServer} = require('wss')\n\ncreateServer(function connectionListener (ws) {\n  ws.send('welcome!')\n  ws.on('message', (data) =\u003e {\n    ws.send(data.toString()) // echo-server\n  })\n})\n.listen(8080, function () {\n  const {address, port} = this.address() // this is the http[s].Server\n  console.log('listening on http://%s:%d (%s)', /::/.test(address) ? '0.0.0.0' : address, port)\n})\n```\n\n#### usage with existent server\n```javascript\nconst {createServer} = require('http')\nconst {createServerFrom} = require('wss')\n\nconst http = createServer()\ncreateServerFrom(http, function connectionListener (ws) {\n  ws.send('welcome!')\n  ws.on('message', (data) =\u003e {\n    ws.send(data.toString()) // echo-server\n  })\n})\nhttp.listen(8080)\n```\n\n### wss\nthe `ws.Server` object is inherited from [ws](http://npmjs.org/ws)\n\n### wss.prototype.close([callback])\nstops the server from accepting new connections.\n\n### wss.prototype.listen(handle[, callback])\nthe `handle` object can be set to either a server or socket (anything with an underlying _handle_ member), or a `{fd}` object. This function is asynchronous. callback will be added as a listener for the `listening` event.\n\n### wss.prototype.listen(path[, callback])\nstart a unix socket server listening for connections on the given path. this function is asynchronous. callback will be added as a listener for the `listening` event.\n\n### wss.prototype.listen([port[, hostname[, backlog[, callback]]]])\nbegin accepting connections on the specified port and hostname. if the hostname is omitted, the server will accept connections on any ipv6 address (::) when ipv6 is available, or any ipv4 address (0.0.0.0) otherwise. omit the port argument, or use a port value of 0, to have the operating system assign a random port, which can be retrieved by using server.address().port after the `listening` event has been emitted.\n\nto listen to a unix socket, supply a filename instead of port and hostname.\n\nbacklog is the maximum length of the queue of pending connections. The actual length will be determined by your OS through sysctl settings such as `tcp_max_syn_backlog` and somaxconn on linux. The default value of this parameter is `511`. This function is asynchronous. `callback` will be added as a listener for the `listening` event.\n\nNote: The server.listen() method may be called multiple times. Each subsequent call will re-open the server using the provided options.\n\n### wss.createServerFrom(server=http.Server|https.Server)\nreturns a new `ws.Server` based on given web server object.\nthrows if no server is given.\n\n### wss.createServer([options[, connectionListener]])\nreturns a new `ws.Server` based on given options and connectionListener. underlaying `https` server is created when `tls` options have been provided as of`tls.createServer()`, otherwise it will fallback to a `http` implementation. the connectionListener is a function which is automatically added to the `connection` event.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivoputzer%2Fwss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivoputzer%2Fwss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivoputzer%2Fwss/lists"}