{"id":13523633,"url":"https://github.com/ic4j/ic4j-websocket","last_synced_at":"2026-01-17T08:39:21.372Z","repository":{"id":207819401,"uuid":"681150611","full_name":"ic4j/ic4j-websocket","owner":"ic4j","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-03T11:32:14.000Z","size":220,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-02T08:30:27.801Z","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/ic4j.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":"2023-08-21T11:32:06.000Z","updated_at":"2024-06-03T11:32:18.000Z","dependencies_parsed_at":"2023-11-25T23:27:14.587Z","dependency_job_id":"d50a0dff-9a61-42de-90eb-1e8b2ba72a42","html_url":"https://github.com/ic4j/ic4j-websocket","commit_stats":null,"previous_names":["ic4j/ic4j-websocket"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ic4j%2Fic4j-websocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ic4j%2Fic4j-websocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ic4j%2Fic4j-websocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ic4j%2Fic4j-websocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ic4j","download_url":"https://codeload.github.com/ic4j/ic4j-websocket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246567131,"owners_count":20798118,"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-01T06:01:02.045Z","updated_at":"2026-01-17T08:39:21.339Z","avatar_url":"https://github.com/ic4j.png","language":"Java","funding_links":[],"categories":["Client Libraries (Agents)"],"sub_categories":["Java/Kotlin"],"readme":"## IC4J Websocket Client\n\nThis Java library implements the ICP Websocket Gateway protocol, allowing any Java application to receive Websocket messages from ICP smart contracts.\n \n \u003ca href=\"https://github.com/omnia-network/ic-websocket-gateway\"\u003e\nhttps://github.com/omnia-network/ic-websocket-gateway\n\u003c/a\u003e\n \n\n# Build\n\nYou need JDK 8+ to build IC4J Websocket Agent.\n\n# License\n\nIC4J Websocket is available under Apache License 2.0.\n\n\n# Documentation\n\n```\nKeyPair keyPair = KeyPairGenerator.getInstance(\"Ed25519\").generateKeyPair();\n\nBasicIdentity identity = BasicIdentity.fromKeyPair(keyPair);\n\nReplicaTransport httpTransport = ReplicaOkHttpTransport.create(env.getProperty(\"ic.location\"));\n\t\t\t\nfinal WebsocketTransport wsTransport = new JavaxWebsocketTransport(new URI(env.getProperty(\"ws.location\")), httpTransport);\n\t\t\t\n\nWsAgent wsAgent = new WsAgent( Principal.fromString(env.getProperty(\"ic.canister\")),\n\t\t\t\t\twsTransport, identity).setLocal(Boolean.parseBoolean(env.getProperty(\"local\",\"false\")));\n\t\t\t\nwsAgent\n.addMessageHandler((output) -\u003e {\n\ttry {\n\t\t\tAppMessage result = IDLArgs.fromBytes(output).getArgs().get(0).getValue(new PojoDeserializer(), AppMessage.class);\n\t\t\tLOG.info(result.text);\n\t\t\t\t\t\t\t\n\t\t\tAppMessage response = new AppMessage();\n\t\t\t\t\t\t\t\n\t\t\tresponse.text = \"Pong\";\n\t\t\t\t\t\t\t\n\t\t\tresponse.timestamp = System.currentTimeMillis();\n\t\t\t\t\t\t\t\n\t\t\tbyte[] payload = WsAgent.encodeValue(response);\n\t\t\t\t\t\t\t\n\t\t\twsAgent.sendApplicationMessage(payload);\n\t\t} catch (Exception e) {\n\t\t\tLOG.error(e.getLocalizedMessage(),e);\n\t\t}\n});\t\n\nwsAgent.start();\n\n// wait 100 seconds for messages from websocket\nThread.sleep(100000);\n\t\t\t\nwsAgent.close();\n```\n\n# Downloads / Accessing Binaries\n\nTo add IC4J Websocket library to your Java project use Maven or Gradle import from Maven Central.\n\n\u003ca href=\"https://search.maven.org/artifact/org.ic4j/ic4j-websocket/0.7.0/jar\"\u003e\nhttps://search.maven.org/artifact/org.ic4j/ic4j-websocket/0.7.0/jar\n\u003c/a\u003e\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.ic4j\u003c/groupId\u003e\n  \u003cartifactId\u003eic4j-websocket\u003c/artifactId\u003e\n  \u003cversion\u003e0.7.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n```\nimplementation 'org.ic4j:ic4j-websocket:0.7.0'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fic4j%2Fic4j-websocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fic4j%2Fic4j-websocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fic4j%2Fic4j-websocket/lists"}