Liking cljdoc? Tell your friends :D

rainboots.core

Core interface

Core interface
raw docstring

*svr*clj

source

close!clj

(close! cli)

Disconnect the client

Disconnect the client
sourceraw docstring

default-portclj

source

default-prompt-delayclj

source

default-telnet-optsclj

source

hook!cljmacro

(hook! hook-name fun)
(hook! hook-name options fun)

Install a hook. Hooks are fired with undefined ordering, with each subsequent hook receiving the results of the one before it. The argument(s) passed to a hook are arbitrary, but each hook MUST return the same 'type' of data it received, so as to play nicely with other installed hooks of the same kind.

The name of a hook is similarly arbitrary---it may be a String or a Keyword or whatever you want, as long as you use it consistently.

Install a hook. Hooks are fired with undefined ordering, with each
 subsequent hook receiving the results of the one before it. The
 argument(s) passed to a hook are arbitrary, but each hook MUST
 return the same 'type' of data it received, so as to play nicely
 with other installed hooks of the same kind.

The name of a hook is similarly arbitrary---it may be a String or a
 Keyword or whatever you want, as long as you use it consistently.
sourceraw docstring

pop-cmds!clj

(pop-cmds! cli)

Pop the top-most cmdset from the user's input stack. See push-cmds!

Pop the top-most cmdset from the user's input stack. See push-cmds!
sourceraw docstring

push-cmds!clj

(push-cmds! cli cmd-set)

Push a new cmdset to the top of the user's input stack. Only function at the top of this stack receives input. This is only meaningful if you haven't provided your own on-cmd handler (but why would you?). The provided cmd-set can be anything declared with (defcmdset), or, in fact, any function that looks like (fn [on-404 can-exec? cli input]), where:

on-404 is the function configured for when a command doesn't exist;

can-exec? is a (fn [cli cmd]), where cmd is the a fn created by defcmd that cli is hoping to execute.

cli is the client providing the input; and

input is the raw String input line

Push a new cmdset to the top of the user's input stack. Only
 function at the top of this stack receives input. This is only
 meaningful if you haven't provided your own on-cmd handler (but why
 would you?).  The provided cmd-set can be anything declared with
 (defcmdset), or, in fact, any function that looks like (fn [on-404
 can-exec? cli input]), where:

`on-404` is the function configured for when a command doesn't exist;

`can-exec?` is a (fn [cli cmd]), where `cmd` is the a fn created by
 defcmd that `cli` is hoping to execute.

`cli` is the client providing the input; and

`input` is the raw String input line
sourceraw docstring

send!clj

(send! cli & body)
(send! process-extras cli & body)

Send text to the client. You can pass in a variable number of args, which may in turn be strings, vectors, or functions. Vectors will be treated as additional varargs (IE: (apply)'d to this function). Functions will be called with the client as a single argument, and the result sent as if it were passed directly. Strings, and any string returned by a function argument or in a vector, will be processed for color sequences (see the colors module).

Maps will be treated as telnet sequences (see telnet!) Strings are processed via the :process-send! hook, which is how the colors are applied. :process-send! is triggered with a map containing the recipient as :cli and the text as :text.

You may optionally provide a map as the first argument, before the client object, whose keys and values will also be passed along in the map for the :process-send! hook.

Send text to the client. You can pass in a variable number of
 args, which may in turn be strings, vectors, or functions. Vectors
 will be treated as additional varargs (IE: (apply)'d to this
 function).  Functions will be called with the client as a single
 argument, and the result sent as if it were passed directly.
 Strings, and any string returned by a function argument or in a
 vector, will be processed for color sequences (see the colors
 module).

Maps will be treated as telnet sequences (see telnet!) Strings are
 processed via the :process-send! hook, which is how the colors are
 applied. :process-send!  is triggered with a map containing the
 recipient as :cli and the text as :text.

You may optionally provide a map as the first argument, before the
 client object, whose keys and values will also be passed along in
 the map for the :process-send! hook.
sourceraw docstring

send-all!clj

(send-all! & body)
(send-all! process-extras & body)

Send text to every connected client. This is a convenience function. See send! for the meaning of the optional process-extras

Send text to every connected client. This is a convenience
function. See send! for the meaning of the optional
process-extras
sourceraw docstring

send-if!clj

(send-if! pred & body)
(send-if! process-extras pred & body)

Send text to every connected client for which (pred cli) returns true. The message body will be handled in the same way (send!) handles it. See send! for the meaning of the optional process-extras.

Send text to every connected client for which (pred cli) returns
true. The message body will be handled in the same way (send!)
handles it. See send! for the meaning of the optional
process-extras.
sourceraw docstring

start-servercljmacro

(start-server
  &
  {:keys [port telnet-opts can-exec? on-auth on-cmd on-404 on-err on-connect
          on-disconnect on-prompt prompt-delay on-telnet]
   :or {port default-port
        telnet-opts default-telnet-opts
        can-exec? (clojure.core/seq (clojure.core/concat
                                      (clojure.core/list
                                        (quote clojure.core/constantly))
                                      (clojure.core/list (quote true))))
        on-404 (clojure.core/seq
                 (clojure.core/concat
                   (clojure.core/list (quote clojure.core/fn))
                   (clojure.core/list
                     (clojure.core/apply
                       clojure.core/vector
                       (clojure.core/seq
                         (clojure.core/concat
                           (clojure.core/list (quote cli__17373__auto__))
                           (clojure.core/list (quote &))
                           (clojure.core/list (quote etc__17374__auto__))))))
                   (clojure.core/list
                     (clojure.core/seq
                       (clojure.core/concat
                         (clojure.core/list (quote rainboots.core/send!))
                         (clojure.core/list (quote cli__17373__auto__))
                         (clojure.core/list "Huh?"))))))
        on-err (clojure.core/seq
                 (clojure.core/concat
                   (clojure.core/list (quote clojure.core/fn))
                   (clojure.core/list
                     (clojure.core/apply
                       clojure.core/vector
                       (clojure.core/seq
                         (clojure.core/concat
                           (clojure.core/list (quote cli__17375__auto__))
                           (clojure.core/list (quote e__17376__auto__))))))
                   (clojure.core/list
                     (clojure.core/seq
                       (clojure.core/concat
                         (clojure.core/list (quote rainboots.util/log))
                         (clojure.core/list (quote e__17376__auto__)))))
                   (clojure.core/list
                     (clojure.core/seq
                       (clojure.core/concat
                         (clojure.core/list (quote rainboots.core/send!))
                         (clojure.core/list (quote cli__17375__auto__))
                         (clojure.core/list
                           "{Y<< {RERROR: {WSomething went wrong. {Y>>{n"))))))
        on-disconnect (clojure.core/seq (clojure.core/concat
                                          (clojure.core/list
                                            (quote clojure.core/constantly))
                                          (clojure.core/list (quote nil))))
        prompt-delay default-prompt-delay
        on-telnet (clojure.core/seq (clojure.core/concat
                                      (clojure.core/list
                                        (quote clojure.core/constantly))
                                      (clojure.core/list (quote nil))))}
   :as opts})

Start up a server with the provided callbacks and options. This is a macro so that you can supply function references and still easily update them via repl.

Options: :port Port on which to start the server :prompt-delay Milliseconds to wait after a send! to trigger :on-prompt :telnet-opts A set of handled telnet op codes. Rainboots will automatically specify 'WILL' for these opts. May be keywords specified in rainboots.proto, or the raw int value. By default, we will handle :term-type and fill out a set in :term-types of the client map

Callbacks: :can-exec? (fn [cli cmd]) Called to check if cli is allowed to execute cmd. Return truthy if yes, else return falsy and notify the client why. Only applies when using the default :on-cmd :on-auth (fn [cli line]) Called on each raw line of input from the client until they have something in the :ch field of the cli atom. This should be where you store the character info. :on-cmd (fn [cli cmd]) Called on each command input from an auth'd client. :on-err (fn [cli e]) Called if a client-executed command throw a Throwable; only applies when using the default on-cmd :on-prompt (fn [cli]) Called when it's time to show the client a prompt. Return a string or a sequence and it will be passed or (apply)'d to (send!), respectively.

Start up a server with the provided callbacks and options. This is a
 macro so that you can supply function references and still easily
 update them via repl.

Options:
:port Port on which to start the server
:prompt-delay Milliseconds to wait after a send! to trigger :on-prompt
:telnet-opts A set of handled telnet op codes. Rainboots will
             automatically specify 'WILL' for these opts. May be
             keywords specified in rainboots.proto, or the raw int
             value. By default, we will handle :term-type and fill
             out a set in :term-types of the client map

Callbacks:
:can-exec? (fn [cli cmd]) Called to check if `cli` is allowed to
           execute `cmd`. Return truthy if yes, else return falsy and
           notify the client why. Only applies when using the default
           :on-cmd
:on-auth (fn [cli line]) Called on each raw line of input from the
         client until they have something in the :ch field of the
         `cli` atom. This should be where you store the character
         info.
:on-cmd (fn [cli cmd]) Called on each command input from an auth'd
        client.
:on-err (fn [cli e]) Called if a client-executed command throw a
        Throwable; only applies when using the default on-cmd
:on-prompt (fn [cli]) Called when it's time to show the client a
           prompt. Return a string or a sequence and it will be
           passed or (apply)'d to (send!), respectively.
sourceraw docstring

stop-serverclj

(stop-server server)
source

telnet!clj

(telnet! cli telnet)

Send a telnet map (like thsoe received in :on-telnet) or a vector of raw bytes as a telnet instruction. Telnet maps can also be sent using (send!) for convenience; note, however, that send! appends an '\r\n' sequence to whatever is passed, so if you ONLY want to send a telnet sequence, this is the way to go.

Send a telnet map (like thsoe received in :on-telnet) or a vector of
raw bytes as a telnet instruction. Telnet maps can also be sent
using (send!) for convenience; note, however, that send! appends an
'\r\n' sequence to whatever is passed, so if you ONLY want to send
a telnet sequence, this is the way to go.
sourceraw docstring

throttleclj

(throttle ch f duration)

Read from ch until it closes, throttling reads such that only the last value emitted without any others following for duration ms will be accepted; read values will be passed to f.

Read from ch until it closes, throttling reads such that only the
last value emitted without any others following for `duration` ms
will be accepted; read values will be passed to f.
sourceraw docstring

trigger!clj

(trigger! hook-name arg)

Trigger a hook kind. hook-name should be a previously installed hook via (hook!), but it is not an error to fire a hook with nothing installed to it. Returns the final result returned from the last-run hook fn, or the input arg itself if no hooks are installed.

Trigger a hook kind. hook-name should be a previously installed hook
via (hook!), but it is not an error to fire a hook with nothing
installed to it.  Returns the final result returned from the
last-run hook fn, or the input arg itself if no hooks are
installed.
sourceraw docstring

unhook!cljmacro

(unhook! hook-name fun)

Uninstall a previously installed hook fn

Uninstall a previously installed hook fn
sourceraw docstring

with-bindscljmacro

(with-binds & body)
source

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

× close