{"id":15103688,"url":"https://github.com/uncharted404/ayb-websocket","last_synced_at":"2026-01-20T01:17:22.820Z","repository":{"id":194702719,"uuid":"691396812","full_name":"uncharted404/ayb-websocket","owner":"uncharted404","description":"基于netty实现的websocket框架","archived":false,"fork":false,"pushed_at":"2023-09-14T05:35:53.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T23:51:12.455Z","etag":null,"topics":["netty","netty-websocket","websocket"],"latest_commit_sha":null,"homepage":"","language":"Java","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/uncharted404.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}},"created_at":"2023-09-14T05:16:48.000Z","updated_at":"2023-09-14T05:18:41.000Z","dependencies_parsed_at":"2023-09-14T19:42:21.781Z","dependency_job_id":null,"html_url":"https://github.com/uncharted404/ayb-websocket","commit_stats":null,"previous_names":["alittlegarbage/ayb-websocket","uncharted404/ayb-websocket"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncharted404%2Fayb-websocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncharted404%2Fayb-websocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncharted404%2Fayb-websocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncharted404%2Fayb-websocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uncharted404","download_url":"https://codeload.github.com/uncharted404/ayb-websocket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247335560,"owners_count":20922457,"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":["netty","netty-websocket","websocket"],"created_at":"2024-09-25T19:41:30.446Z","updated_at":"2026-01-20T01:17:22.770Z","avatar_url":"https://github.com/uncharted404.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ayb-websocket\n基于netty实现的websocket框架\n\n## 介绍\nayb-websocket基于netty实现了websocket框架，集成了spring-boot，开箱即用\n\n## 快速开始\n1. 导入依赖\n   ```\n   \u003cdependency\u003e\n       \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n       \u003cartifactId\u003espring-boot-starter\u003c/artifactId\u003e\n   \u003c/dependency\u003e\n   \u003cdependency\u003e\n       \u003cgroupId\u003ecom.ayb\u003c/groupId\u003e\n       \u003cartifactId\u003eayb-websocket-spring-boot-starter\u003c/artifactId\u003e\n   \u003c/dependency\u003e\n   ```\n2. 实现`AbstractWebSocketMapping\u003cQ, R\u003e`类，搭配`@WebSocket()`配置监听地址以及路径，使用`@Component`装配到Spring容器中\n   ```\n   @Component\n   @WebSocket(port = 9999, path = \"/ws\")\n   public class MyMapping extends AbstractWebSocketMapping\u003cString, String\u003e {\n\n       /**\n        * 接收消息\n        * @param ctx\n        * @param request\n        * @return\n        */\n       @Override\n       protected String onMessage(ChannelHandlerContext ctx, String request) {\n           // 发送事件\n           ctx.pipeline().fireUserEventTriggered(\"接收消息:\" + request);\n           return \"Hello, WebSocket\";\n       }\n   \n       /**\n        * 接收二进制消息\n        * @param ctx\n        * @param content\n        * @return\n        */\n       @Override\n       protected byte[] onBinary(ChannelHandlerContext ctx, byte[] content) {\n           return null;\n       }\n   \n       /**\n        * 客户端下线\n        * @param ctx\n        */\n       @Override\n       protected void onClose(ChannelHandlerContext ctx) {\n           System.out.println(\"客户端\" + ctx.channel().remoteAddress() + \"下线\");\n       }\n   \n       /**\n        * 客户端上线\n        * @param ctx\n        */\n       @Override\n       protected void onOpen(ChannelHandlerContext ctx) {\n           System.out.println(\"客户端\" + ctx.channel().remoteAddress() + \"上线\");\n       }\n   \n       /**\n        * 错误处理\n        * @param ctx\n        * @param cause\n        */\n       @Override\n       protected void onError(ChannelHandlerContext ctx, Throwable cause) {\n           System.out.println(\"出现错误,原因:\" + cause.getMessage());\n       }\n   \n       /**\n        * 监听事件\n        * @param ctx\n        * @param evt\n        */\n       @Override\n       protected void onEvent(ChannelHandlerContext ctx, Object evt) {\n           if (evt instanceof String) {\n               System.out.println(\"事件:\" + evt);\n           }\n       }\n   }\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funcharted404%2Fayb-websocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funcharted404%2Fayb-websocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funcharted404%2Fayb-websocket/lists"}