(-activity! connection)(-activity! connection moment)(-activity-since? connection moment)(-add-connection! client path csrf-token cid socket)(-cancel-timeout! timeout)(-channel-on-close server connection-id _ status)(-connection-cursor server connection-id)(-connection-cursor state)(-connection-uri path connection-id csrf-token)(-connection-uri location path connection-id csrf-token)(-create-timeout! server connection request-id timeout-millis)(-data-received server connection-id socket data)(-data-received client e)(-do-call! state connection kind params handler options)(-handle-close client _)(-handle-error client e)(-handle-open client _)(-handle-response connection response)(-new-scheduler)(-open-connection! server request connection-id channel)(-ping! state connection)(-ping-inactive-connections! state)(-schedule-with-delay scheduler state interval)(-socket-send! socket data)(-timeout! server connection request-id)(call! state connection-id kind)(call! state connection-id kind params)(call! state connection-id kind params handler & options)(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:
(close! state connection-id)Close the connection with connection-id
Close the connection with connection-id
(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
(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.
(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
(connection-request! server conn-atom kind params responder)(connection-responder! conn-atom id)(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
(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
(open? server connection-id)(open? client)(pack message)(request id kind)(request id kind params)(request id kind params reply?)(request? message)(response id data)(response? message)(unpack data)cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |