{"id":15782888,"url":"https://github.com/marihachi/websocket-events","last_synced_at":"2026-04-10T16:44:23.722Z","repository":{"id":94818561,"uuid":"93443373","full_name":"marihachi/websocket-events","owner":"marihachi","description":"user events for WebSocket-Node","archived":false,"fork":false,"pushed_at":"2018-12-04T17:49:56.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-24T15:26:26.490Z","etag":null,"topics":["events","json","nodejs","websocket"],"latest_commit_sha":null,"homepage":null,"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/marihachi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2017-06-05T20:22:12.000Z","updated_at":"2019-07-20T16:33:20.000Z","dependencies_parsed_at":"2023-04-04T18:01:19.687Z","dependency_job_id":null,"html_url":"https://github.com/marihachi/websocket-events","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"2e8444976de01470a3fb7801949d6bc9e2ceddec"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marihachi%2Fwebsocket-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marihachi%2Fwebsocket-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marihachi%2Fwebsocket-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marihachi%2Fwebsocket-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marihachi","download_url":"https://codeload.github.com/marihachi/websocket-events/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246500184,"owners_count":20787655,"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":["events","json","nodejs","websocket"],"created_at":"2024-10-04T19:21:56.139Z","updated_at":"2026-04-10T16:44:23.675Z","avatar_url":"https://github.com/marihachi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# websocket-events\nuser events for [WebSocket-Node](https://github.com/theturtle32/WebSocket-Node) connections.\n\n[![NPM](https://nodei.co/npm/websocket-events.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/websocket-events/)\n\n## Installation\n\tnpm i websocket-events\n\n## Usage\n```js\nconst websocket = require('websocket');\nconst events = require('websocket-events');\n\n/* -- instance creation of http.Server is omitted -- */\n\nconst server = new websocket.server({httpServer: http});\n\nserver.on('request', request =\u003e {\n\tconst connection = request.accept();\n\n\tconnection.on('error', err =\u003e {\n\t\tif (err.userEventError) {\n\t\t\tconsole.log('user event error:', err);\n\t\t}\n\t\telse {\n\t\t\tconsole.log('error:', err);\n\t\t}\n\t});\n\n\tconnection.on('close', (reasonCode, description) =\u003e {\n\t\tconsole.log('closed:', reasonCode, description);\n\t});\n\n\t// use here\n\tconst options = {};\n\tevents(connection, options);\n\n\tconnection.on('user-event', data =\u003e {\n\t\tconsole.log('user-event:', data);\n\t});\n\n\t// this listener is only used when not set listeners\n\tconnection.on('default', event =\u003e {\n\t\tconsole.log('default listener:', event.name, event.content);\n\t});\n\n\t// send user event as message of json data\n\tconnection.send('user-event', { hoge: 'piyo' });\n\n\t// send normal text message\n\tconnection.send('normal message');\n});\n```\n:bulb: The example is used on the server, but it can also be used on the client.\n\n## Usable Options\n### eventKeyName\nThe name used as key of event name.\nDefault value is `@event`.\n\n### defaultEventName\nThe name used when event listeners is not set.\nDefault value is `default`.\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarihachi%2Fwebsocket-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarihachi%2Fwebsocket-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarihachi%2Fwebsocket-events/lists"}