{"id":13736464,"url":"https://github.com/ryo-ma/deno-websocket","last_synced_at":"2025-04-08T04:19:50.296Z","repository":{"id":42064074,"uuid":"264689002","full_name":"ryo-ma/deno-websocket","owner":"ryo-ma","description":"🦕 A simple WebSocket library like ws of node.js library for deno","archived":false,"fork":false,"pushed_at":"2023-04-30T03:42:10.000Z","size":64,"stargazers_count":153,"open_issues_count":9,"forks_count":19,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T18:05:30.397Z","etag":null,"topics":["deno","deno-websocket","rfc-6455","typescript","websocket","websocket-client","websocket-library","websocket-server","ws"],"latest_commit_sha":null,"homepage":"https://deno.land/x/websocket","language":"TypeScript","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/ryo-ma.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}},"created_at":"2020-05-17T14:45:33.000Z","updated_at":"2025-02-09T16:34:42.000Z","dependencies_parsed_at":"2024-06-21T16:46:13.083Z","dependency_job_id":"93c140c4-cd1b-45a1-aecd-9ee78dfe0d8a","html_url":"https://github.com/ryo-ma/deno-websocket","commit_stats":{"total_commits":81,"total_committers":7,"mean_commits":"11.571428571428571","dds":"0.11111111111111116","last_synced_commit":"9e52a3fd659cf8b86f431de5a4d488d9d4632075"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryo-ma%2Fdeno-websocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryo-ma%2Fdeno-websocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryo-ma%2Fdeno-websocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryo-ma%2Fdeno-websocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryo-ma","download_url":"https://codeload.github.com/ryo-ma/deno-websocket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773968,"owners_count":20993678,"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":["deno","deno-websocket","rfc-6455","typescript","websocket","websocket-client","websocket-library","websocket-server","ws"],"created_at":"2024-08-03T03:01:22.272Z","updated_at":"2025-04-08T04:19:50.267Z","avatar_url":"https://github.com/ryo-ma.png","language":"TypeScript","funding_links":[],"categories":["基础设施","Modules"],"sub_categories":["Deno 源","Online Playgrounds","WebSocket","Assistants"],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/ryo-ma/deno-websocket/master/.assets/logo.png\" width=\"200\" alt=\"logo\"/\u003e\n\u003c/div\u003e\n\n# deno websocket\n\n[![deno doc](https://img.shields.io/badge/deno-doc-informational?logo=deno)](https://doc.deno.land/https/deno.land/x/denon/mod.ts)\n![GitHub](https://img.shields.io/github/license/ryo-ma/deno-websocket)\n[![nest badge](https://nest.land/badge.svg)](https://nest.land/package/deno-websocket)\n\n🦕 A simple WebSocket library like [ws of node.js library](https://github.com/websockets/ws) for deno\n\nThis library is wrapping the [ws standard library](https://github.com/denoland/deno_std/tree/main/ws) as a server-side and the [native WebSocket API](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) as a client-side. \nYou can receive callbacks at the EventEmitter and can use the same object format on both the server-side and the client-side.\n\n\n* Deno \u003e= 1.8.3\n\n\n# Quick Start\n\n## Example Demo\n\n![demo](https://user-images.githubusercontent.com/6661165/84665958-6df6d880-af5b-11ea-91b8-24c5122ddf9a.gif)\n\nServer side\n\n```bash\n$ deno run --allow-net https://deno.land/x/websocket@v0.1.4/example/server.ts\n```\n\nClient side\n\n```bash\n$ deno run --allow-net https://deno.land/x/websocket@v0.1.4/example/client.ts\nws connected! (type 'close' to quit)\n\u003e something\n```\n\n## Usage\n\nServer side\n\n```typescript\nimport { WebSocketClient, WebSocketServer } from \"https://deno.land/x/websocket@v0.1.4/mod.ts\";\n\nconst wss = new WebSocketServer(8080);\nwss.on(\"connection\", function (ws: WebSocketClient) {\n  ws.on(\"message\", function (message: string) {\n    console.log(message);\n    ws.send(message);\n  });\n});\n\n```\n\nClient side\n\n```typescript\nimport { WebSocketClient, StandardWebSocketClient } from \"https://deno.land/x/websocket@v0.1.4/mod.ts\";\nconst endpoint = \"ws://127.0.0.1:8080\";\nconst ws: WebSocketClient = new StandardWebSocketClient(endpoint);\nws.on(\"open\", function() {\n  console.log(\"ws connected!\");\n  ws.send(\"something\");\n});\nws.on(\"message\", function (message: string) {\n  console.log(message);\n});\n```\n\n# Documentation\n\n## WebSocketServer\n\n### Event\n\n| event | detail|\n| --- | --- |\n| connection | Emitted when the handshake is complete |\n| error | Emitted when an error occurs |\n\n### Field\n\n| field | detail | type |\n| --- | --- | --- |\n| server.clients | A set that stores all connected clients | Set\\\u003cWebSocket\\\u003e |\n\n### Method\n\n| method | detail |\n| --- | --- |\n| close() | Close the server |\n\n## WebSocketClient\n\n### Event\n\n| event | detail|\n| --- | --- |\n| open | Emitted when the connection is established |\n| close | Emitted when the connection is closed |\n| message | Emitted when a message is received from the server |\n| ping | Emitted when a ping is received from the server |\n| pong | Emitted when a pong is received from the server |\n| error | Emitted when an error occurs |\n\n### Field\n\n| field | detail | type |\n| --- | --- | --- |\n| websocket.isClosed | Get the close flag | Boolean \\| undefined |\n\n### Method\n\n| method | detail |\n| --- | --- |\n| send(message:string \\| Unit8Array) | Send a message |\n| ping(message:string \\| Unit8Array) | Send the ping |\n| close([code:int[, reason:string]]) | Close the connection with the server |\n| forceClose() | Forcibly close the connection with the server |\n\n\n# LICENSE\n[MIT LICENSE](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryo-ma%2Fdeno-websocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryo-ma%2Fdeno-websocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryo-ma%2Fdeno-websocket/lists"}