{"id":13848782,"url":"https://github.com/kyleduo/iCometClient4j","last_synced_at":"2025-07-12T13:32:22.485Z","repository":{"id":15597419,"uuid":"18333480","full_name":"kyleduo/iCometClient4j","owner":"kyleduo","description":"Client of iComet server for Java/Android. iComet server: https://github.com/ideawu/icomet","archived":false,"fork":false,"pushed_at":"2014-11-21T16:18:42.000Z","size":3406,"stargazers_count":115,"open_issues_count":3,"forks_count":65,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-07-01T10:55:51.137Z","etag":null,"topics":[],"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/kyleduo.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}},"created_at":"2014-04-01T15:03:05.000Z","updated_at":"2024-05-17T13:16:30.000Z","dependencies_parsed_at":"2022-09-06T23:20:52.119Z","dependency_job_id":null,"html_url":"https://github.com/kyleduo/iCometClient4j","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/kyleduo%2FiCometClient4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyleduo%2FiCometClient4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyleduo%2FiCometClient4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyleduo%2FiCometClient4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyleduo","download_url":"https://codeload.github.com/kyleduo/iCometClient4j/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213949803,"owners_count":15661676,"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-08-04T19:00:57.465Z","updated_at":"2024-08-04T19:03:21.366Z","avatar_url":"https://github.com/kyleduo.png","language":"Java","funding_links":[],"categories":["Java","网络编程"],"sub_categories":["Spring Cloud框架"],"readme":"iCometClient4j\n===\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-iCometClient4j-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1120)\n\nClient of iComet server for Java/Android. iComet server: https://github.com/ideawu/icomet\n\nThis project is based the iComet service which can be found in https://github.com/ideawu/icomet created by ideawu(www.ideawu.com).\n\nSimply, this project is an implements of client for iComet service. You can use it in your java project as well as Android project.\n\nIf you want to know what the effect of this client is look at, there's an demo in Java prepared for running in none auth mode. Obviously, you need an iComet server. Mine is run on my mac under default configuration.\n\n### Demo\n\nThere are two demos in this project for Java android Android. \n\nThe one for Android is based on the one for Java by using the release jar file. You can find it in https://github.com/ideawu/icomet-demos , where you can also find a updated website demo. \n\nAndroidDemo can be your reference in your own project, but it is suggested that you should implement the logic yourself to match your own business. If there are bugs, please mail me.\n\n### Usage\n\nHere's some decription of how to use this client.\n\nUsing getInstance() method to get an instance of ICometClient.\n\nBefore you connet to the iComet server, you should make the client prepared with the ICometConf object by calling prepare(ICometConf) method. The ICometConf object should be completely initialed with those params which you can find under.\n\n\tmClient = ICometClient.getInstance();\n\n\tICometConf conf = new ICometConf();\n\tconf.host = \"127.0.0.1\";\n\tconf.port = \"8100\";\n\tconf.url = \"stream\";\n\tconf.iConnCallback = new MyConnCallback();\n\tconf.iCometCallback = new MyCometCallback();\n\tconf.channelAllocator = new NoneAuthChannelAllocator();\n\n\tmClient.prepare(conf);\n\nAs you can see, there are one ChannelAllocator and two Callbacks for your business. \n\nThe ChannelAllocator is used to connect to your own server and request a channel for connetiong to iComet server and a token for authorization if you need it. Also, seq is configurated in this allocator, such that you can decide whether to fetch some old message of that channel. There is only one method in this interface for now:\n\t\n\tallocate();\n\nAs their names say, the two Callbacks is used for connection and fetching process separately. It is important that you should always implement these two interface and put them into ICometConf object. Following by a outline of these two Callbacks:\n\n\tIConnCallback {\n\n\t\tpublic void onFail(String msg);\n\n\t\tpublic void onSuccess();\n\n\t\tpublic void onDisconnect();\n\n\t\tpublic void onStop();\n\t\n\t\tpublic boolean onReconnect(int times);\n\t\n\t\tpublic void onReconnectSuccess(int times);\n\t}\n\n\tICometCallback {\n\n\t\tpublic void onDataMsgArrived(Message.Content content);\n\n\t\tpublic void onMsgArrived(Message msg);\n\n\t\tpublic void onErrorMsgArrived(Message msg);\n\t\t\n\t\tpublic void onMsgFormatError();\n\t}\n\nWhen the client is ready, just a invoke of connect() method will connect it to iComet server. If you use this client in an Android project, you should invoke this method in an children thread, otherwise you would get a NetworkOnMainThreadException.\n\nThen the IConnCallback will be invoked, if there's nothing wrong, you can use comet() method to listen the connection and you will receive the messages from iCometServer which you can deal with them by ICometCallback.\n\nThere's something else to know about the ICometCallback, the onMsgArrived() method will be invoked when any message arrive while onDataMsgArrived() and onErrorMsgArrived() will be invoked on for arriving of specific message related to their name.\n\nMuch more information will be in wiki and docs pages soon.\n\nHave fun with it!\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyleduo%2FiCometClient4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyleduo%2FiCometClient4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyleduo%2FiCometClient4j/lists"}