Liking cljdoc? Tell your friends :D

c3kit.wire.websocketc


-activity!clj/s

(-activity! connection)
(-activity! connection moment)

-activity-since?clj/s

(-activity-since? connection moment)

-add-connection!cljs

(-add-connection! client path csrf-token cid socket)

-cancel-timeout!clj/s

(-cancel-timeout! timeout)

-channel-on-closeclj

(-channel-on-close server connection-id _ status)

-close-socket!clj/s


-connection-cursorclj/s≠

clj
(-connection-cursor server connection-id)
cljs
(-connection-cursor state)

-connection-uricljs

(-connection-uri path connection-id csrf-token)
(-connection-uri location path connection-id csrf-token)

-create-timeout!clj/s

(-create-timeout! server connection request-id timeout-millis)

-data-receivedclj/s≠

clj
(-data-received server connection-id socket data)
cljs
(-data-received client e)

-do-call!clj/s

(-do-call! state connection kind params handler options)

-handle-closecljs

(-handle-close client _)

-handle-errorcljs

(-handle-error client e)

-handle-opencljs

(-handle-open client _)

-handle-responseclj/s

(-handle-response connection response)

-new-schedulerclj

(-new-scheduler)

-open-connection!clj

(-open-connection! server request connection-id channel)

-ping!clj/s

(-ping! state connection)

-ping-inactive-connections!clj/s

(-ping-inactive-connections! state)

-schedule-with-delayclj

(-schedule-with-delay scheduler state interval)

-socket-send!cljs

(-socket-send! socket data)

-timeout!clj/s

(-timeout! server connection request-id)

call!clj/s≠

clj
(call! state connection-id kind)
(call! state connection-id kind params)
(call! state connection-id kind params handler & options)
cljs
(call! state kind)
(call! state kind params)
(call! state kind params handler & options)

Make a websocket RPC.

state - client or sever state (from create fn) connection-id - (server only) to select the client connection you want to call kind - used to dispatch behavior, typically a keyword params - (optional) any clj form (data) needed to support the :kind of request handler - (optional) (fn [RESPONSE]) invoked when a response to the request is received (reply? implied true)

OPTIONS - a map and/or key/value pairs:

Make a websocket RPC.

state         - client or sever state (from create fn)
connection-id - (server only) to select the client connection you want to call
kind          - used to dispatch behavior, typically a keyword
params        - (optional) any clj form (data) needed to support the :kind of request
handler       - (optional) (fn [RESPONSE]) invoked when a response to the request is received (reply? implied true)

OPTIONS - a map and/or key/value pairs:
raw docstring

close!clj/s≠

clj
(close! state connection-id)

Close the connection with connection-id

Close the connection with connection-id
cljs
(close! state)
(close! state code-or-reason)
(close! state code reason)

Close the connection. code (optional) https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#status_codes reason (optional) A human-readable string explaining why the connection is closing

Close the connection.
code   (optional) https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#status_codes
reason (optional) A human-readable string explaining why the connection is closing
raw docstring

connect!cljs

(connect! client path csrf-token)

Open a websocket connection to the server.

client - client state atom path - URI path to the websocket handler. The protocol and host are determined by the window location. csrf-token - required for security. Default strategy is session/key from server.

Open a websocket connection to the server.

client     - client state atom
path       - URI path to the websocket handler.  The protocol and host are determined by the window location.
csrf-token - required for security.  Default strategy is session/key from server.
raw docstring

connectionclj/s

(connection id socket)

Returns a map holding connection data. A connection will contain, but is not limited to, these keys:

:id - a unique string id for the connection :socket - network communication channel :request-counter - to generate next request id in sequence for this connection :open? - boolean :responders - (maybe) map of request-id -> (fn [payload]) to handle responses :last-active-at - time of last send or receive of data

Returns a map holding connection data.  A connection will contain, but is not limited to, these keys:

:id               - a unique string id for the connection
:socket           - network communication channel
:request-counter  - to generate next request id in sequence for this connection
:open?            - boolean
:responders       - (maybe) map of request-id -> (fn [payload]) to handle responses
:last-active-at   - time of last send or receive of data
raw docstring

connection-request!clj/s

(connection-request! server conn-atom kind params responder)

connection-responder!clj/s

(connection-responder! conn-atom id)

createclj/s

(create message-handler & args)

Returns a atom to hold all the state and configuration to run a websocket client or server.

message-handler - (fn [REQUEST]) to handle incoming RPC requests.

REQUEST: :request-id - each connection has it's own sequence starting at 1 :kind - used to dispatch behavior (see BUILTIN KINDS below) :params - any clj form (data) needed to support the :kind of request :reply? - true iff a response is expected :connection-id - uniquely identifying the connection to the server :request - (server only) the ring request that initiated the websocket connection

BUILTIN KINDS (values for :kind key in requests) :ws/open - a connection is opened {:params nil} :ws/close - a connection is closed {:params nil} :ws/hello - sent from server to client when a connection is opened {:params nil} :ws/error - an error occurred {:params error-map} :ws/timeout - a request with {:reply? true} did not receive a response within :request-timeout milliseconds

RESPONSE: :response-id - id corresponding to originating request :payload - any form

OPTIONS - a map and/or key/value pairs: :on-data - (fn [data]) when incoming data fails to parse (edn) or satisfy request? or response? :request-timeout - (default: 5000) milliseconds to wait before cancelling request. nil -> never timeout. :atom-fn - (default: core/atom) type of atom to story the state. Maybe reagent/atom. :ping-interval - (default: 30) seconds between keep-alive pings on inactive connections. nil -> no pings

Returns a atom to hold all the state and configuration to run a websocket client or server.

message-handler - (fn [REQUEST]) to handle incoming RPC requests.

REQUEST:
:request-id    - each connection has it's own sequence starting at 1
:kind          - used to dispatch behavior (see BUILTIN KINDS below)
:params        - any clj form (data) needed to support the :kind of request
:reply?        - true iff a response is expected
:connection-id - uniquely identifying the connection to the server
:request       - (server only) the ring request that initiated the websocket connection

BUILTIN KINDS (values for :kind key in requests)
:ws/open       - a connection is opened {:params nil}
:ws/close      - a connection is closed {:params nil}
:ws/hello      - sent from server to client when a connection is opened {:params nil}
:ws/error      - an error occurred {:params error-map}
:ws/timeout    - a request with {:reply? true} did not receive a response within :request-timeout milliseconds

RESPONSE:
:response-id   - id corresponding to originating request
:payload       - any form

OPTIONS - a map and/or key/value pairs:
:on-data         	- (fn [data]) when incoming data fails to parse (edn) or satisfy request? or response?
:request-timeout 	- (default: 5000) milliseconds to wait before cancelling request.  nil -> never timeout.
:atom-fn      		- (default: core/atom) type of atom to story the state. Maybe reagent/atom.
:ping-interval	 	- (default: 30) seconds between keep-alive pings on inactive connections. nil -> no pings
raw docstring

handlerclj

(handler server request)

Ring handler to open websocket connections in the specified server state atom.

server - server state atom (from create) request - ring request

Ring handler to open websocket connections in the specified server state atom.

server  - server state atom (from create)
request - ring request
raw docstring

open?clj/s≠

clj
(open? server connection-id)
cljs
(open? client)

packclj/s

(pack message)

requestclj/s

(request id kind)
(request id kind params)
(request id kind params reply?)

request?clj/s

(request? message)

responseclj/s

(response id data)

response?clj/s

(response? message)

unpackclj/s

(unpack data)

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close