{"id":18914499,"url":"https://github.com/angeloavv/laravel-jecho-client","last_synced_at":"2025-04-15T08:31:17.418Z","repository":{"id":91538086,"uuid":"139325984","full_name":"AngeloAvv/laravel-jecho-client","owner":"AngeloAvv","description":"A Java client compatible with Laravel Echo Server","archived":false,"fork":false,"pushed_at":"2018-07-07T11:25:46.000Z","size":10,"stargazers_count":4,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T22:29:31.669Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AngeloAvv.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-01T12:08:20.000Z","updated_at":"2021-10-15T02:40:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"7ca17665-0458-42ff-80eb-78e4962e757e","html_url":"https://github.com/AngeloAvv/laravel-jecho-client","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloAvv%2Flaravel-jecho-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloAvv%2Flaravel-jecho-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloAvv%2Flaravel-jecho-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloAvv%2Flaravel-jecho-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AngeloAvv","download_url":"https://codeload.github.com/AngeloAvv/laravel-jecho-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249035460,"owners_count":21202089,"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-08T10:11:44.464Z","updated_at":"2025-04-15T08:31:17.406Z","avatar_url":"https://github.com/AngeloAvv.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel jEcho Client\nA Java client compatible with Laravel Echo Server\n\n### What is it?\nLaravel jEcho Client uses the java-based [socket.io-client](https://github.com/nkzawa/socket.io-client) library\ndeveloped by [nkzawa](https://github.com/nkzawa) to easily interface your Java application to a\n[Laravel Echo Server](https://github.com/tlaverdure/laravel-echo-server).\n\n### Compatibility\n* Socket.IO\n\n### Getting started\nSince this library works as a wrapper, it's mandatory to properly configure your Laravel environment.\nKeep in mind that this library works only using the **auth:api** guard,\nas we need to pass the api key to let it work.\nYou can follow these links as long as they can help you with the configuration:\n* [How to use Laravel with Socket.IO](https://medium.com/@adnanxteam/how-to-use-laravel-with-socket-io-e7c7565cc19d)\n* [HOWTO: broadcasting, laravel-echo, laravel-echo-server and JWT](https://laravel.io/forum/10-09-2016-howto-broadcasting-laravel-echo-laravel-echo-server-and-jwt)\n\nOnce you have a fully working Laravel Echo environment, you can proceed with the next steps.\n\nAdditional information on broadcasting with Laravel can be found on the official docs: https://laravel.com/docs/master/broadcasting\n\n### Setup\nWe need to include the Laravel jEcho Client as a library inside our project\n\n##### Gradle\n1. Add the JitPack repository to your build file\n```gradle\nallprojects {\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n2. Add the dependency\n```gradle\ndependencies {\n    implementation 'com.github.AngeloAvv:laravel-jecho-client:0.1.1'\n}\n```\n\n##### Maven\n1. Add the JitPack repository to your build file\n```maven\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n2. Add the dependency\n```maven\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.AngeloAvv\u003c/groupId\u003e\n    \u003cartifactId\u003elaravel-jecho-client\u003c/artifactId\u003e\n    \u003cversion\u003e0.1.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nNext you need to create an Echo instance as it follows:\n```java\nOptions options = new Options();\noptions.url = \"http://localhost:6001\";\noptions.namespace = \"App.Events\";\noptions.token = \"apiToken\";\n\nEcho instance = new Echo(options);\n```\n\nWhen you create a new Echo instance, the client tries to connect to the Socket.IO\nserver. In this phase your application must be able to connect to the network.\n\n### Listening to events\nYou can setup your Echo instance to listen for a specific event registered for\na specific channel using the listen method.\n```java\ninstance.listen(\"channel-name\", \"event\", new Channel.OnEvent\u003cJSONObject\u003e() {\n    public void onEvent(JSONObject arg) {\n\n    }\n});\n```\n\n### Joining channels\nThe library is able to satisfy almost all of the Laravel Echo behaviors. You can join\nto private, presence and public channels. The code looks the same as the js implementation.\n\n##### Joining Private Channels\n```java\ninstance.privateChannel(\"channel-name\")\n.listen(\"event\", new Channel.OnEvent\u003cJSONObject\u003e() {\n    @Override\n    public void onEvent(JSONObject arg) {\n\n    }\n});\n```\n##### Joining Presence Channels\n```java\ninstance.join(\"channel-name\")\n.here(new PresenceChannel.OnUsersHereListener() {\n    @Override\n    public void onUsersHere(int... ids) {\n\n    }\n})\n.joining(new PresenceChannel.OnUserJoiningListener() {\n    @Override\n    public void onUserJoining(int id) {\n\n    }\n})\n.leaving(new PresenceChannel.OnUserLeavingListener() {\n    @Override\n    public void onUserLeaving(int id) {\n\n    }\n});\n```\n\n#### Joining Public Channels\n```java\ninstance.channel(\"channel-name\")\n    .listen(\"event\", new Channel.OnEvent\u003cJSONObject\u003e() {\n        @Override\n        public void onEvent(JSONObject arg) {\n\n        }\n    });\n```\n\nThe event listener supports Java Generics, so you can switch between JSONObject\nand JSONArray class types to satisfy your needs.\n\n##### Leaving Channels\nWhen you're done, remember to leave the channel using the following syntax:\n```java\ninstance.leave(\"channel-name\");\n```\n\n### Disconnecting\nSince Socket.IO is based on WebSockets, you need to close the connection when\neverything is done.\n```java\ninstance.disconnect();\n```\n\n### Future\n* Pusher integration\n* JSON event payload deserialization through Gson, Jackson or Moshi\n\n### Features\nAndroid shoud be fully supported.\nThis library is still a work-in-progress. Please feel free to submit new\nissues if you encounter some problems with it.\n\n### Licence\nLaravel jEcho Client is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangeloavv%2Flaravel-jecho-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangeloavv%2Flaravel-jecho-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangeloavv%2Flaravel-jecho-client/lists"}