{"id":27996631,"url":"https://github.com/nilenso/wscljs","last_synced_at":"2025-08-10T15:16:57.367Z","repository":{"id":62433819,"uuid":"103130085","full_name":"nilenso/wscljs","owner":"nilenso","description":"A thin and lightweight websocket client for ClojureScript.","archived":false,"fork":false,"pushed_at":"2019-05-14T16:22:04.000Z","size":21,"stargazers_count":39,"open_issues_count":2,"forks_count":4,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-07-11T05:54:07.387Z","etag":null,"topics":["clojure","clojurescript","websocket-client"],"latest_commit_sha":null,"homepage":"","language":"Clojure","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/nilenso.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":"2017-09-11T11:56:27.000Z","updated_at":"2024-08-16T15:08:15.000Z","dependencies_parsed_at":"2022-11-01T21:16:13.852Z","dependency_job_id":null,"html_url":"https://github.com/nilenso/wscljs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/nilenso/wscljs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nilenso%2Fwscljs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nilenso%2Fwscljs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nilenso%2Fwscljs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nilenso%2Fwscljs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nilenso","download_url":"https://codeload.github.com/nilenso/wscljs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nilenso%2Fwscljs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269740554,"owners_count":24467802,"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-10T02:00:08.965Z","response_time":71,"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","clojurescript","websocket-client"],"created_at":"2025-05-08T21:47:35.161Z","updated_at":"2025-08-10T15:16:57.244Z","avatar_url":"https://github.com/nilenso.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wscljs\n\n[![CircleCI](https://circleci.com/gh/nilenso/wscljs.svg?style=svg)](https://circleci.com/gh/nilenso/wscljs) [![Clojars\nProject](https://img.shields.io/clojars/v/nilenso/wscljs.svg)](https://clojars.org/nilenso/wscljs) [![Cljdoc badge](https://cljdoc.org/badge/nilenso/wscljs)](https://cljdoc.org/d/nilenso/wscljs/0.1.3/doc/readme)\n\nA thin and lightweight(no external dependencies) websocket client for\nClojureScript.\n\n## Why did we write this?\n\nThere are already existing Clojure/Clojurescript websocket libraries like [Sente](https://github.com/ptaoussanis/sente)\nand [Chord](https://github.com/jarohen/chord). However these libraries support creating both websocket server and\nclient. This requires additional dependencies which we didn't want. Wscljs is a\nthin wrapper over the Javascript websockets and brings in no extra\ndependency.\n\n## Usage\n\n```clojure\n(require '[wscljs.client :as ws]\n```\n\nTo create a new websocket connection:\n\n```clojure\n(def socket (ws/create \"ws://....\" handlers))\n```\n\nwhere `handlers` is a map containing handler functions mapped to the following keys:\n\nRequired:\n\n  - `:on-message` =\u003e called when recieving message on the socket\n\nOptional:\n\n  - `:on-open`    =\u003e called when opening a socket connection\n  - `:on-close`   =\u003e called when closing a socket connection\n  - `:on-error`   =\u003e called when an error is received\n\nFor example, to print the data received by the socket, do:\n```clojure\n(def handlers {:on-message (fn [e] (prn (.-data e)))\n               :on-open    #(prn \"Opening a new connection\")\n               :on-close   #(prn \"Closing a connection\")})\n(def socket (ws/create \"ws://....\" handlers))\n```\nTo send json data over the socket, do:\n\n```clojure\n(require '[wscljs.format :as fmt])\n\n(ws/send socket {:command \"ping\"} fmt/json)\n```\n\n**The supported formats are:**\n\n- `json`\n- `edn`\n- `identity`\n\nAfter you're done, close the socket:\n\n```clojure\n(ws/close socket)\n```\n\n## Setup\n\nTo get an interactive development environment run:\n\n```shell\nlein figwheel\n```\n\nand open your browser at [localhost:3449](http://localhost:3449/).\nThis will auto compile and send all changes to the browser without the\nneed to reload. After the compilation process is complete, you will\nget a Browser Connected REPL. An easy way to try it is:\n\n```clojure\n(js/alert \"Am I connected?\")\n```\n\nand you should see an alert in the browser window.\n\nTo clean all compiled files:\n\n```shell\nlein clean\n```\n\nTo create a production build run:\n\n```shell\nlein do clean, cljsbuild once min\n```\n\nAnd open your browser in `resources/public/index.html`. You will not\nget live reloading, nor a REPL.\n\n## Testing\n\nInorder to run tests, you need to have [PhantomJS](http://phantomjs.org/)\ninstalled. After installing it, run the tests:\n\n```shell\nlein test\n```\n\n*Note: I've only tested this with Phantom 2.1.1. As per [this comment](https://github.com/nilenso/wscljs/issues/4#issuecomment-435992513), using \u003c 2.x may not work.*\n\n\n## Authors\n\n- Abhik Khanra (@trycatcher)\n- Kiran Gangadharan (@kirang89)\n- Udit Kumar (@yudistrange)\n\n## License\n\nCopyright © 2017 Nilenso Software  LLP\n\nDistributed under the Eclipse Public License either version 1.0 or (at your option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnilenso%2Fwscljs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnilenso%2Fwscljs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnilenso%2Fwscljs/lists"}