{"id":18854870,"url":"https://github.com/noear/fineio","last_synced_at":"2026-02-05T18:30:19.865Z","repository":{"id":145378717,"uuid":"266705185","full_name":"noear/FineIO","owner":"noear","description":"Nio and aio ","archived":false,"fork":false,"pushed_at":"2020-10-13T22:20:15.000Z","size":192,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-30T18:38:48.160Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noear.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-25T06:49:21.000Z","updated_at":"2020-07-15T08:15:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"7b43403e-017e-4bef-8bf2-f94ece3c8553","html_url":"https://github.com/noear/FineIO","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/noear%2FFineIO","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noear%2FFineIO/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noear%2FFineIO/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noear%2FFineIO/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noear","download_url":"https://codeload.github.com/noear/FineIO/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239793064,"owners_count":19697893,"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-11-08T03:52:00.584Z","updated_at":"2026-02-05T18:30:19.792Z","avatar_url":"https://github.com/noear.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FineIO\n基于NIO实现的轻量级通讯框架\n\n## 特性\n\n暂无...\n\n## 示例\n\n\n### 服务端\n```java\npublic class ServerTest {\n    public static void main(String[] args) {\n        //定义代理\n        //\n        MessageHandler\u003cString\u003e handler = (session, message)-\u003e{\n                System.out.println(\"我收到：\" + message);\n                Thread.sleep(10);\n                session.write(\"我收到：\" + message);\n        };\n\n        //启动服务\n        //\n        FineIO.server(new StringProtocol())\n                .bind(\"localhost\", 8080)\n                .handle(handler.pools()) //handler.pools() //线程池模式\n                .start(false);\n    }\n}\n```\n\n### 客户端\n```java\npublic class ClientTest1 {\n    public static void main(String[] args) {\n        //定义代理\n        //\n        MessageHandler\u003cString\u003e handler = (session, message)-\u003e{\n            System.out.println(\"客户端：收到：\" + message);\n        };\n\n        //定义客户端（内置连接池功能）\n        //\n        var client = FineIO.client(new StringProtocol()).handle(handler).bind(\"localhost\", 8080);\n\n        //测试（请先启动服务端）\n        //\n        client.send(\"测试1\");\n        client.send(\"测试2\");\n    }\n}\n```\n\n### 编码协议\n```java\npublic class StringProtocol implements Protocol\u003cString\u003e {\n    @Override\n    public String decode(ByteBuffer buffer) {\n        if (buffer.remaining() \u003e Integer.BYTES) {\n            int size = buffer.getInt();\n\n            if (size \u003e 0 \u0026\u0026 size \u003c= buffer.remaining()) {\n                byte[] bytes = new byte[size];\n                buffer.get(bytes);\n\n                return new String(bytes);\n            }\n        }\n\n        return null;\n    }\n\n    @Override\n    public ByteBuffer encode(String message) {\n        byte[] bytes = message.getBytes();\n\n        ByteBuffer buf = ByteBuffer.allocateDirect(bytes.length + Integer.BYTES);\n\n        buf.putInt(bytes.length);\n        buf.put(bytes);\n        buf.flip();\n\n        return buf;\n    }\n}\n```\n\n## 性能报告\n\n暂无...","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoear%2Ffineio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoear%2Ffineio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoear%2Ffineio/lists"}