{"id":20173730,"url":"https://github.com/codeestx/rxsocketclient","last_synced_at":"2025-08-19T15:03:38.725Z","repository":{"id":63887918,"uuid":"96703182","full_name":"codeestX/RxSocketClient","owner":"codeestX","description":":rocket:Reactive Socket APIs for Android, Java and Kotlin, powered by RxJava2","archived":false,"fork":false,"pushed_at":"2017-11-19T08:31:42.000Z","size":148,"stargazers_count":49,"open_issues_count":4,"forks_count":17,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T03:37:34.215Z","etag":null,"topics":["android-library","kotlin","rxjava2","socket"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/codeestX.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}},"created_at":"2017-07-09T18:27:25.000Z","updated_at":"2024-01-09T07:34:18.000Z","dependencies_parsed_at":"2022-11-28T14:46:15.167Z","dependency_job_id":null,"html_url":"https://github.com/codeestX/RxSocketClient","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/codeestX/RxSocketClient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeestX%2FRxSocketClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeestX%2FRxSocketClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeestX%2FRxSocketClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeestX%2FRxSocketClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeestX","download_url":"https://codeload.github.com/codeestX/RxSocketClient/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeestX%2FRxSocketClient/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271172958,"owners_count":24711663,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["android-library","kotlin","rxjava2","socket"],"created_at":"2024-11-14T01:37:39.080Z","updated_at":"2025-08-19T15:03:38.693Z","avatar_url":"https://github.com/codeestX.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RxSocketClient\n\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/codeestX/RxSocketClient/pulls) [![API](https://img.shields.io/badge/API-20%2B-brightgreen.svg)](https://android-arsenal.com/api?level=20) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)[![](https://jitpack.io/v/codeestX/RxSocketClient.svg)](https://jitpack.io/#codeestX/RxSocketClient)\n\nRxSocketClient, Reactive Socket APIs for Android, Java and Kotlin, powered by RxJava2  \nRxSocketClient，支持Android，Java和Kotlin的响应式Socket APIs封装，基于RxJava2\n\nRxJava2 Version: 2.1.1\n\n# Usage\n\nStep 1. Add the JitPack repository to your build file\n\n\tallprojects {\n\t\trepositories {\n\t\t\t...\n\t\t\tmaven { url \"https://jitpack.io\" }\n\t\t}\n\t}\n   \nStep 2. Add the dependency\n\n\tdependencies {\n\t        compile 'com.github.codeestX:RxSocketClient:v1.0.1'\n\t}\n\t\n### init\n```java\nSocketClient mClient = RxSocketClient\n        .create(new SocketConfig.Builder()\n                .setIp(IP)\n                .setPort(PORT)\n                .setCharset(Charsets.UTF_8)\n                .setThreadStrategy(ThreadStrategy.ASYNC)\n                .setTimeout(30 * 1000)\n                .build())\n        .option(new SocketOption.Builder()\n                .setHeartBeat(HEART_BEAT, 60 * 1000)\n                .setHead(HEAD)\n                .setTail(TAIL)\n                .build());\n\n```\n| value | default | description |\n| :--: | :--: | :--: |\n| Ip | required | host address |\n| Port | required | port number |\n| Charset | UTF_8 | the charset when encode a String to byte[] |\n| ThreadStrategy | Async | sending data asynchronously or synchronously|\n| Timeout | 0 | the timeout of a connection, millisecond |\n| HeartBeat | Optional | value and interval of heartbeat, millisecond |\n| Head | Optional | appending bytes at head when sending data, not included heartbeat |\n| Tail | Optional | appending bytes at last when sending data, not included heartbeat |\n\n### connect\n```java\nDisposable ref = mClient.connect()\n\t... // anything else what you can do with RxJava\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SocketSubscriber() {\n                    @Override\n                    public void onConnected() {\n                        //onConnected\n                        Log.e(TAG, \"onConnected\");\n                    }\n\n                    @Override\n                    public void onDisconnected() {\n                        //onDisconnected\n                        Log.e(TAG, \"onDisconnected\");\n                    }\n\n                    @Override\n                    public void onResponse(@NotNull byte[] data) {\n                        //receive data\n                        Log.e(TAG, Arrays.toString(data));\n                    }\n                }, new Consumer\u003cThrowable\u003e() {\n                    @Override\n                    public void accept(Throwable throwable) throws Exception {\n                        //onError\n                        Log.e(TAG, throwable.toString());\n                    }\n                });\n```\n\n### disconnect\n```java\nmClient.disconnect();\n//or\nref.dispose();\n```\n\n### sendData\n```java\nmClient.sendData(bytes);\n//or\nmClient.sendData(string);\n```\n\n# License\n\n      Copyright (c) 2017 codeestX\n\n      Licensed under the Apache License, Version 2.0 (the \"License\");\n      you may not use this file except in compliance with the License.\n      You may obtain a copy of the License at\n\n         http://www.apache.org/licenses/LICENSE-2.0\n\n      Unless required by applicable law or agreed to in writing, software\n      distributed under the License is distributed on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n      See the License for the specific language governing permissions and\n      limitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeestx%2Frxsocketclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeestx%2Frxsocketclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeestx%2Frxsocketclient/lists"}