{"id":32191771,"url":"https://github.com/nijohando/event.websocket","last_synced_at":"2025-10-22T01:50:17.895Z","repository":{"id":62433138,"uuid":"148034363","full_name":"nijohando/event.websocket","owner":"nijohando","description":"Websocket client for clojure integrated with nijohando/event","archived":false,"fork":false,"pushed_at":"2019-01-14T11:12:08.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T01:49:37.431Z","etag":null,"topics":["clojure","websocket-client"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nijohando.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":"2018-09-09T14:38:48.000Z","updated_at":"2019-01-14T11:11:54.000Z","dependencies_parsed_at":"2022-11-01T21:01:34.687Z","dependency_job_id":null,"html_url":"https://github.com/nijohando/event.websocket","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nijohando/event.websocket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nijohando%2Fevent.websocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nijohando%2Fevent.websocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nijohando%2Fevent.websocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nijohando%2Fevent.websocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nijohando","download_url":"https://codeload.github.com/nijohando/event.websocket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nijohando%2Fevent.websocket/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280365582,"owners_count":26318385,"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-10-21T02:00:06.614Z","response_time":58,"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":["clojure","websocket-client"],"created_at":"2025-10-22T01:50:13.514Z","updated_at":"2025-10-22T01:50:17.891Z","avatar_url":"https://github.com/nijohando.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# event.websocket\n\n[![Clojars Project](https://img.shields.io/clojars/v/jp.nijohando/event.websocket.svg)](https://clojars.org/jp.nijohando/event.websocket)\n[![CircleCI](https://circleci.com/gh/nijohando/event.websocket.svg?style=shield)](https://circleci.com/gh/nijohando/event.websocket)\n\nExperimental websocket client integrated with [nijohando/event](https://github.com/nijohando/event) bus.\n\n## Installation\n\n#### Ligningen / Boot\n\n```clojure\n[jp.nijohando/event.websocket \"0.1.2\"]\n```\n\n#### Clojure CLI / deps.edn\n\n```clojure\njp.nijohando/event.websocket {:mvn/version \"0.1.2\"}\n```\n\n## Usage\n\n```clojure\n(require '[jp.nijohando.event :as ev]\n         '[jp.nijohando.event.websocket :as ws]\n         '[clojure.core.async :as ca])\n```\n\n#### Bus integration\n\nThis library provides only 3 functions that are `client`, `connect!` and `disconnect!`.\n\n\nFunction `client` creates an event bus that acts as a websocket client.\n\n```clojure\n(def bus (ws/client))\n```\n\nFunction `connect!` connects the bus with the websocket server.\n\n```clojure\n(ws/connect! bus \"wss://echo.websocket.org\")\n```\n\nFunction `disconnect!` disconnects the session from the websocket server.\n\n```clojure\n(ws/disconnect! bus)\n```\n\nAll other operations are channel based operations with [nijohando/event](https://github.com/nijohando/event) API.\n\n\n### Listening to websocket events\n\nVarious events related to websocket can be read from the listener channel.\n\n```clojure\n(def bus (ws/client))\n(def listener (ca/chan))\n(ev/listen bus \"/*\" listener)\n(ca/go-loop []\n  (when-some [{:keys [path value] :as event} (ca/\u003c! listener)]\n    (condp = path\n      \"/connect\"           (prn \"connected!\")\n      \"/connect-failed\"    (prn \"connect-failed!\")\n      \"/disconnect\"        (prn \"disconnected!\")\n      \"/disconnect-failed\" (prn \"disconnect-failed!\")\n      \"/message/text\"      (prn \"text message arrived!\")\n      \"/message/binary\"    (prn \"binary message arrived!\")\n      \"/message/pong\"      (prn \"pong message arrived!\")\n      \"/error\"             (prn \"error!\" value)\n      (prn \"other event \" path))\n    (recur)))\n(ws/connect! bus \"wss://echo.websocket.org\")\n;=\u003e \"connected!\"\n; \"pong message arrived!\"\n```\n\n### Sending messages \n\nMessages can be sent via the emitter channel.  \n\n```clojure\n(def bus (ws/client))\n(def emitter (ca/chan))\n(def listener (ca/chan))\n(ev/emitize bus emitter)\n(ev/listen bus [\"/\" [\"connect\"]\n                    [\"message/text\"]\n                    [\"error\"]] listener)\n(ca/go-loop []\n  (when-some [{:keys [path value] :as event} (ca/\u003c! listener)]\n    (condp = path\n      \"/connect\"      (ca/\u003e! emitter (ev/event \"/send/text\" \"hello!\"))\n      \"/message/text\" (prn \"echo message arrivded! \" value)\n      \"/error\"        (prn \"error! \" value))\n    (recur)))\n(ws/connect! bus \"wss://echo.websocket.org\")\n;=\u003e \"echo message arrivded! \" \"hello!\"\n```\n\n## License\n\n© 2018 nijohando  \n\nDistributed under the Eclipse Public License either version 1.0 or (at your option) any later version.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnijohando%2Fevent.websocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnijohando%2Fevent.websocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnijohando%2Fevent.websocket/lists"}