Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A SocketCluster Client library for Clojure.

License

NotificationsYou must be signed in to change notification settings

tuddman/socketcluster-clj

Repository files navigation

ASocketCluster Client library for Clojure. This client wrapssocketcluster-client-java, but where appropriate aims to be more idiomatic and succinct.

Clojars Project

Usage

lein repl;; define=> (require '[socketcluster-clj.client:as sc-client])=> (require '[socketcluster-clj.listeners:as sc-listen])=> (require '[socketcluster-clj.events:as sc-event])=> (require '[socketcluster-clj.channels:as sc-ch])=> (defsc-server-url"ws://localhost:8000/socketcluster/")=> (defmy-socket (sc-client/new-socket sc-server-url)or=> (sc-client/set-url my-socket sc-server-url);; set listener(s)=> (sc-listen/set-listener my-socket);; connect=> (sc-client/connect my-socket);; automatically re-connect=> (sc-client/set-reconnect-strategy my-socket200030);; send event(s) to the server=> (sc-event/emit my-socket {"some""data"});; CHANNELS -;; subscribe=> (sc-ch/create-channel my-socket"channel-name")=> (sc-ch/set-channel-listener my-socket"channel-name" (fn [name data] (print"received on channel =>" name"some data =>" data)))=> (sc-ch/subscribe my-socket"channel-name");; publish=> (sc-ch/publish my-socket"channel-name" {"some""data"})

for more, have a look insrc/socketcluster_clj/<ns>.clj to learn what else you can call.

NPE Issue

if you get the following error when trying to connect:

Exceptionin thread"OkHttp Dispatcher" java.lang.NullPointerExceptionat io.github.sac.Socket$1.onFailure(Socket.java:185)at okhttp3.internal.ws.RealWebSocket.failWebSocket(RealWebSocket.java:546)at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:206)

you need to(sc-listen/set-listener <socket>)before connecting.

License

Copyright © 2019 tuddman

This program and the accompanying materials are made available under theterms of the Eclipse Public License 2.0 which is available athttp://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following SecondaryLicenses when the conditions for such availability set forth in the EclipsePublic License, v. 2.0 are satisfied: GNU General Public License as published bythe Free Software Foundation, either version 2 of the License, or (at youroption) any later version, with the GNU Classpath Exception which is availableathttps://www.gnu.org/software/classpath/license.html.

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp