{"id":16905700,"url":"https://github.com/octref/wsfun","last_synced_at":"2026-05-19T00:05:35.956Z","repository":{"id":85550519,"uuid":"145280038","full_name":"octref/wsfun","owner":"octref","description":"WebSockets fun","archived":false,"fork":false,"pushed_at":"2018-08-19T07:23:11.000Z","size":6,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-25T15:13:18.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/octref.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-19T06:47:07.000Z","updated_at":"2022-03-06T04:47:39.000Z","dependencies_parsed_at":"2023-03-04T07:30:27.933Z","dependency_job_id":null,"html_url":"https://github.com/octref/wsfun","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/octref%2Fwsfun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octref%2Fwsfun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octref%2Fwsfun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octref%2Fwsfun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/octref","download_url":"https://codeload.github.com/octref/wsfun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244647231,"owners_count":20487034,"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":[],"created_at":"2024-10-13T18:39:20.041Z","updated_at":"2026-05-19T00:05:33.257Z","avatar_url":"https://github.com/octref.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebSockets Fun\n\n## Usage\n\n- `yarn`\n- Run Node Server: `yarn server`\n- Run Node Client: `yarn client`\n- Run Browser Client: Go to http://localhost:4000 and play with `window.socket` in browser\n\n## Links:\n\n[RFC](https://tools.ietf.org/html/rfc6455) | [WebSockets API on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)\n\n[Armin Ronacher](http://lucumr.pocoo.org/2012/9/24/websockets-101/) | [Popular Medium Article]( https://blog.sessionstack.com/how-javascript-works-deep-dive-into-websockets-and-http-2-with-sse-how-to-pick-the-right-path-584e6b8e3bf7)\n\n[`websockets/ws`](https://github.com/websockets/ws) | [`websockets/ws API`](https://github.com/websockets/ws/blob/master/doc/ws.md)\n\n## Notes\n\n### URL\n\n`ws://` for 80 and `wss://` for 443.\n\n### Framing: OpCode\n\n- `0x00`: this frame continues the payload from the last.\n- `0x01`: this frame includes utf-8 text data.\n- `0x02`: this frame includes binary data.\n- `0x08`: this frame terminates the connection.\n- `0x09`: this frame is a ping.\n- `0x0a`: this frame is a pong.\n\n### Framing: Closing Frame\n\n- `1000`: 1000 indicates a normal closure, meaning that the purpose for which the connection was established has been fulfilled.\n- `1001`: 1001 indicates that an endpoint is \"going away\", such as a server going down or a browser having navigated away from a page.\n- `1002`: 1002 indicates that an endpoint is terminating the connection due to a protocol error.\n- `1003`: 1003 indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message).\n\n```js\n// client\nsocket.close(1000, 'close')\n\n// server\nconn.on('close', (code, reason) =\u003e { })\n```\n\n### Libraries\n\nIn Browser, use the native `WebSocket` object.\nFor Server side: [`ws`](https://github.com/websockets/ws) seems decent.\n\n### Ping-Pong\n\nUsually only server sends ping and client responds with pong.\n\n### Heartbeat\n\nhttps://github.com/websockets/ws#how-to-detect-and-close-broken-connections\n\n## License\n\nMIT © [Pine Wu](https://github.com/octref) ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctref%2Fwsfun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctref%2Fwsfun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctref%2Fwsfun/lists"}