Liking cljdoc? Tell your friends :D

fulcro.websockets


externsclj

source

externs-neededclj

source

invokeclj

source

make-easy-server-adapterclj

(make-easy-server-adapter)

Creates a component that relies on :handler and :websockets. You must install Websockets as :websockets in your components.

This will inject the proper Ring handlers into the easy server. See wrap-api for a function that you can use in a custom server.

Creates a component that relies on :handler and :websockets. You must install Websockets as :websockets in your components.

This will inject the proper Ring handlers into the easy server. See wrap-api for a function that you can
use in a custom server.
sourceraw docstring

make-websocket-networkingcljs

(make-websocket-networking)
(make-websocket-networking {:keys [websockets-uri global-error-callback
                                   push-handler host req-params state-callback
                                   transit-handlers auto-retry? sente-options]})

Creates a websocket-based networking component for use as a Fulcro remote.

Params:

  • websockets-uri - The uri to handle websocket traffic on. (ex. "/chsk", which is the default value)
  • push-handler - A function (fn [{:keys [topic msg]}] ...) that can handle a push message. The topic is the server push verb, and the message will be the EDN sent.
  • host - Host option to send to sente
  • req-params - Params for sente socket creation
  • transit-handlers - A map with optional :read and :write keys that given added sente packer.
  • state-callback (Optional) - Callback that runs when the websocket state of the websocket changes. The function takes an old state parameter and a new state parameter (arity 2 function). state-callback can be either a function, or an atom containing a function.
  • global-error-callback - A function (fn [resp] ...) that is called when returned status code from the server is not 200.
  • auto-retry? - A boolean (default false). If set to true any network disconnects will lead to infinite retries until the network returns. All remote mutations should be idempotent.
  • sente-options - A map of options that is passed directly to the sente websocket channel construction (see sente docs).
Creates a websocket-based networking component for use as a Fulcro remote.

Params:
- `websockets-uri` - The uri to handle websocket traffic on. (ex. "/chsk", which is the default value)
- `push-handler` - A function (fn [{:keys [topic msg]}] ...) that can handle a push message.
                   The topic is the server push verb, and the message will be the EDN sent.
- `host` - Host option to send to sente
- `req-params` - Params for sente socket creation
- `transit-handlers` - A map with optional :read and :write keys that given added sente packer.
- `state-callback` (Optional) - Callback that runs when the websocket state of the websocket changes.
                                The function takes an old state parameter and a new state parameter (arity 2 function).
                                `state-callback` can be either a function, or an atom containing a function.
- `global-error-callback` - A function (fn [resp] ...) that is called when returned status code from the server is not 200.
- `auto-retry?` - A boolean (default false). If set to true any network disconnects will lead to infinite retries until
                  the network returns. All remote mutations should be idempotent.
- `sente-options` - A map of options that is passed directly to the sente websocket channel construction (see sente docs).
sourceraw docstring

make-websocketsclj

(make-websockets parser
                 {:keys [websockets-uri http-server-adapter transit-handlers
                         sente-options]})

Build a web sockets component with the given API parser and sente socket server options (see sente docs). NOTE: If you supply a packer, you'll need to make sure tempids are supported (this is done by default, but if you override it, it is up to you. The default user id mapping is to use the internally generated UUID of the client. Use sente's :user-id-fn option to override this.

Anything injected as a dependency of this component is added to your parser environment (in addition to the parser itself).

Thus, if you'd like some other component (like a database) to be there, simply do this:

(component/using (make-websockets parser {}) [:sql-database :sessions])

and when the system starts it will inject those components into this one, and this one will be your parser env.

Additionally, the parser environment will include: :websockets The channel server component itself :push A function that can send push messages to any connected client of this server. (just a shortcut to send-fn in websockets) :parser The parser you gave this function :sente-message The raw sente event.

The websockets component must be joined into a real network server via a ring stack. This implementation assumes http-kit. The wrap-api function can be used to do that.

All of the options in the options map are optional.

If you don't supply a server adapter, it defaults to http-kit. If you don't supply websockets-uri, it defaults to "/chsk".

Build a web sockets component with the given API parser and sente socket server options (see sente docs).
NOTE: If you supply a packer, you'll need to make sure tempids are supported (this is done by default, but if you override it, it is up to you.
The default user id mapping is to use the internally generated UUID of the client. Use sente's `:user-id-fn` option
to override this.

Anything injected as a dependency of this component is added to your parser environment (in addition to the parser
itself).

Thus, if you'd like some other component (like a database) to be there, simply do this:

(component/using (make-websockets parser {})
  [:sql-database :sessions])

and when the system starts it will inject those components into this one, and this one will be your parser env.

Additionally, the parser environment will include:
  :websockets The channel server component itself
  :push           A function that can send push messages to any connected client of this server. (just a shortcut to send-fn in websockets)
  :parser         The parser you gave this function
  :sente-message  The raw sente event.

The websockets component must be joined into a real network server via a ring stack. This implementation assumes http-kit.
The `wrap-api` function can be used to do that.

All of the options in the options map are optional.

If you don't supply a server adapter, it defaults to http-kit.
If you don't supply websockets-uri, it defaults to "/chsk".
sourceraw docstring

sente-event-handlerclj

(sente-event-handler {:keys [send-fn listeners parser] :as websockets} event)

A sente event handler that connects the websockets support up to the parser via the :fulcro.client/API event, and also handles notifying listeners that clients connected and dropped.

A sente event handler that connects the websockets support up to the parser via the
:fulcro.client/API event, and also handles notifying listeners that clients connected and dropped.
sourceraw docstring

Websocketscljs

source

wrap-apiclj

(wrap-api handler websockets)

Add API support to a Ring middleware chain. The websockets argument is an initialized Websockets component. Basically inject websockets into the component where you define your middleware, and (-> handler ... (wrap-api websockets) ...).

NOTE: You must have wrap-keyword-params and wrap-params in the middleware chain!

Add API support to a Ring middleware chain. The websockets argument is an initialized Websockets component. Basically
inject websockets into the component where you define your middleware, and (-> handler ... (wrap-api websockets) ...).

NOTE: You must have wrap-keyword-params and wrap-params in the middleware chain!
sourceraw docstring

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

× close