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

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__17299__auto__))
                           (clojure.core/list (quote &))
                           (clojure.core/list (quote etc__17300__auto__))))))
                   (clojure.core/list
                     (clojure.core/seq
                       (clojure.core/concat
                         (clojure.core/list (quote rainboots.core/send!))
                         (clojure.core/list (quote cli__17299__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__17301__auto__))
                           (clojure.core/list (quote e__17302__auto__))))))
                   (clojure.core/list
                     (clojure.core/seq
                       (clojure.core/concat
                         (clojure.core/list (quote rainboots.util/log))
                         (clojure.core/list (quote e__17302__auto__)))))
                   (clojure.core/list
                     (clojure.core/seq
                       (clojure.core/concat
                         (clojure.core/list (quote rainboots.core/send!))
                         (clojure.core/list (quote cli__17301__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

with-bindscljmacro

(with-binds & body)
source

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

× close