<h1>OOB<aclass="headerlink"href="#oob"title="Permalink to this headline">¶</a></h1>
<p>OOB, or Out-Of-Band, means sending data between Evennia and the user’s client without the user prompting it or necessarily being aware that it’s being passed. Common uses would be to update client health-bars, handle client button-presses or to display certain tagged text in a different window pane.</p>
<h2>Briefly on input/outputcommands<aclass="headerlink"href="#briefly-on-input-outputcommands"title="Permalink to this headline">¶</a></h2>
<p>Inside Evennia, all server-client communication happens in the same way (so plain text is also an ‘OOB message’ as far as Evennia is concerned). The message follows the <aclass="reference internal"href="Messagepath.html"><spanclass="doc">Message Path</span></a>. You should read up on that if you are unfamiliar with it. As the message travels along the path it has a standardized internal form: a tuple with a string, a tuple and a dict:</p>
<p>This is often referred to as an <em>inputcommand</em> or <em>outputcommand</em>, depending on the direction it’s traveling. The end point for an inputcommand, (the ‘Evennia-end’ of the message path) is a matching <aclass="reference internal"href="Inputfuncs.html"><spanclass="doc">Inputfunc</span></a>. This function is called as <codeclass="docutils literal notranslate"><spanclass="pre">cmdname(session,</span><spanclass="pre">*args,</span><spanclass="pre">**kwargs)</span></code> where <codeclass="docutils literal notranslate"><spanclass="pre">session</span></code> is the Session-source of the command. Inputfuncs can easily be added by the developer to support/map client commands to actions inside Evennia (see the <aclass="reference internal"href="Inputfuncs.html"><spanclass="doc">inputfunc</span></a> page for more details).</p>
<p>When a message is outgoing (at the ‘Client-end’ of the message path) the outputcommand is handled by a matching <em>Outputfunc</em>. This is responsible for converting the internal Evennia representation to a form suitable to send over the wire to the Client. Outputfuncs are hard-coded. Which is chosen and how it processes the outgoing data depends on the nature of the client it’s connected to. The only time one would want to add new outputfuncs is as part of developing support for a new Evennia <aclass="reference internal"href="Custom-Protocols.html"><spanclass="doc">Protocol</span></a>.</p>
<h2>Sending and receiving an OOB message<aclass="headerlink"href="#sending-and-receiving-an-oob-message"title="Permalink to this headline">¶</a></h2>
<p>Sending is simple. You just use the normal <codeclass="docutils literal notranslate"><spanclass="pre">msg</span></code> method of the object whose session you want to send to. For example in a Command:</p>
<p>A special case is the <codeclass="docutils literal notranslate"><spanclass="pre">text</span></code> input/outputfunc. It’s so common that it’s the default of the <codeclass="docutils literal notranslate"><spanclass="pre">msg</span></code> method. So these are equivalent:</p>
<p>You don’t have to specify the full output/input definition. So for example, if your particular command only needs kwargs, you can skip the <codeclass="docutils literal notranslate"><spanclass="pre">(args)</span></code> part. Like in the <codeclass="docutils literal notranslate"><spanclass="pre">text</span></code> case you can skip writing the tuple if there is only one arg … and so on - the input is pretty flexible. If there are no args at all you need to give the empty tuple <codeclass="docutils literal notranslate"><spanclass="pre">msg(cmdname=(,)</span></code> (giving <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code> would mean a single argument <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>).</p>
<p>Which commands you can send depends on the client. If the client does not support an explicit OOB protocol (like many old/legacy MUD clients) Evennia can only send <codeclass="docutils literal notranslate"><spanclass="pre">text</span></code> to them and will quietly drop any other types of outputfuncs.</p>
<blockquote>
<div><p>Remember that a given message may go to multiple clients with different capabilities. So unless you turn off telnet completely and only rely on the webclient, you should never rely on non-<codeclass="docutils literal notranslate"><spanclass="pre">text</span></code> OOB messages always reaching all targets.</p>
</div></blockquote>
<p><aclass="reference internal"href="Inputfuncs.html"><spanclass="doc">Inputfuncs</span></a> lists the default inputfuncs available to handle incoming OOB messages. To accept more you need to add more inputfuncs (see that page for more info).</p>
</div>
<divclass="section"id="supported-oob-protocols">
<h2>Supported OOB protocols<aclass="headerlink"href="#supported-oob-protocols"title="Permalink to this headline">¶</a></h2>
<p>Evennia supports clients using one of the following protocols:</p>
<divclass="section"id="telnet">
<h3>Telnet<aclass="headerlink"href="#telnet"title="Permalink to this headline">¶</a></h3>
<p>By default telnet (and telnet+SSL) supports only the plain <codeclass="docutils literal notranslate"><spanclass="pre">text</span></code> outputcommand. Evennia however detects if the Client supports one of two MUD-specific OOB <em>extensions</em> to the standard telnet protocol - GMCP or MSDP. Evennia supports both simultaneously and will switch to the protocol the client uses. If the client supports both, GMCP will be used.</p>
<blockquote>
<div><p>Note that for Telnet, <codeclass="docutils literal notranslate"><spanclass="pre">text</span></code> has a special status as the “in-band” operation. So the <codeclass="docutils literal notranslate"><spanclass="pre">text</span></code> outputcommand sends the <codeclass="docutils literal notranslate"><spanclass="pre">text</span></code> argument directly over the wire, without going through the OOB translations described below.</p>
</div></blockquote>
<divclass="section"id="telnet-gmcp">
<h4>Telnet + GMCP<aclass="headerlink"href="#telnet-gmcp"title="Permalink to this headline">¶</a></h4>
<p><aclass="reference external"href="http://www.gammon.com.au/gmcp">GMCP</a>, the <em>Generic Mud Communication Protocol</em> sends data on the form <codeclass="docutils literal notranslate"><spanclass="pre">cmdname</span><spanclass="pre">+</span><spanclass="pre">JSONdata</span></code>. Here the cmdname is expected to be on the form “Package.Subpackage”. There could also be additional Sub-sub packages etc. The names of these ‘packages’ and ‘subpackages’ are not that well standardized beyond what individual MUDs or companies have chosen to go with over the years. You can decide on your own package names, but here are what others are using:</p>
<li><p><aclass="reference external"href="http://nexus.ironrealms.com/GMCP">IRE games GMCP</a></p></li>
</ul>
<p>Evennia will translate underscores to <codeclass="docutils literal notranslate"><spanclass="pre">.</span></code> and capitalize to fit the specification. So the outputcommand <codeclass="docutils literal notranslate"><spanclass="pre">foo_bar</span></code> will become a GMCP command-name <codeclass="docutils literal notranslate"><spanclass="pre">Foo.Bar</span></code>. A GMCP command “Foo.Bar” will be come <codeclass="docutils literal notranslate"><spanclass="pre">foo_bar</span></code>. To send a GMCP command that turns into an Evennia inputcommand without an underscore, use the <codeclass="docutils literal notranslate"><spanclass="pre">Core</span></code> package. So <codeclass="docutils literal notranslate"><spanclass="pre">Core.Cmdname</span></code> becomes just <codeclass="docutils literal notranslate"><spanclass="pre">cmdname</span></code> in Evennia and vice versa.</p>
<p>On the wire, a GMCP instruction for <codeclass="docutils literal notranslate"><spanclass="pre">("cmdname",</span><spanclass="pre">("arg",),</span><spanclass="pre">{})</span></code> will look like this:</p>
<p>where all the capitalized words are telnet character constants specified in <codeclass="docutils literal notranslate"><spanclass="pre">evennia/server/portal/telnet_oob.py</span></code>. These are parsed/added by the protocol and we don’t include these in the listings below.</p>
<p>Since Evennia already supplies default inputfuncs that don’t match the names expected by the most common GMCP implementations we have a few hard-coded mappings for those:</p>
<h2>GMCP command name | Input/Outputfunc name<aclass="headerlink"href="#gmcp-command-name-input-outputfunc-name"title="Permalink to this headline">¶</a></h2>
<p>“Core.Hello” | “client_options”
“Core.Supports.Get” | “client_options”
“Core.Commands.Get” | “get_inputfuncs”
“Char.Value.Get” | “get_value”
“Char.Repeat.Update” | “repeat”
“Char.Monitor.Update” | “monitor”</p>
<divclass="section"id="telnet-msdp">
<h3>Telnet + MSDP<aclass="headerlink"href="#telnet-msdp"title="Permalink to this headline">¶</a></h3>
<p><aclass="reference external"href="http://tintin.sourceforge.net/msdp/">MSDP</a>, the <em>Mud Server Data Protocol</em>, is a competing standard to GMCP. The MSDP protocol page specifies a range of “recommended” available MSDP command names. Evennia does <em>not</em> support those - since MSDP doesn’t specify a special format for its command names (like GMCP does) the client can and should just call the internal Evennia inputfunc by its actual name.</p>
<p>MSDP uses Telnet character constants to package various structured data over the wire. MSDP supports strings, arrays (lists) and tables (dicts). These are used to define the cmdname, args and kwargs needed. When sending MSDP for <codeclass="docutils literal notranslate"><spanclass="pre">("cmdname",</span><spanclass="pre">("arg",),</span><spanclass="pre">{})</span></code> the resulting MSDP instruction will look like this:</p>
<h2>Outputfunc/Inputfunc | MSDP instruction<aclass="headerlink"href="#outputfunc-inputfunc-msdp-instruction"title="Permalink to this headline">¶</a></h2>
<p><codeclass="docutils literal notranslate"><spanclass="pre">[cmdname,</span><spanclass="pre">[],</span><spanclass="pre">{}]</span></code> | VAR cmdname VAL
<codeclass="docutils literal notranslate"><spanclass="pre">[cmdname,</span><spanclass="pre">[arg],</span><spanclass="pre">{}]</span></code> | VAR cmdname VAL arg
<codeclass="docutils literal notranslate"><spanclass="pre">[cmdname,</span><spanclass="pre">[args],{}]</span></code> | VAR cmdname VAL ARRAYOPEN VAL arg VAL arg … ARRAYCLOSE
<codeclass="docutils literal notranslate"><spanclass="pre">[cmdname,</span><spanclass="pre">[],</span><spanclass="pre">{kwargs}]</span></code> | VAR cmdname VAL TABLEOPEN VAR key VAL val … TABLECLOSE
<codeclass="docutils literal notranslate"><spanclass="pre">[cmdname,</span><spanclass="pre">[args],</span><spanclass="pre">{kwargs}]</span></code> | VAR cmdname VAL ARRAYOPEN VAL arg VAL arg … ARRAYCLOSE VAR cmdname VAL TABLEOPEN VAR key VAL val … TABLECLOSE</p>
<p>Observe that <codeclass="docutils literal notranslate"><spanclass="pre">VAR</span><spanclass="pre">...</span><spanclass="pre">VAL</span></code> always identifies cmdnames, so if there are multiple arrays/dicts tagged with the same cmdname they will be appended to the args, kwargs of that inputfunc. Vice-versa, a different <codeclass="docutils literal notranslate"><spanclass="pre">VAR</span><spanclass="pre">...</span><spanclass="pre">VAL</span></code> (outside a table) will come out as a second, different command input.</p>
<divclass="section"id="ssh">
<h3>SSH<aclass="headerlink"href="#ssh"title="Permalink to this headline">¶</a></h3>
<p>SSH only supports the <codeclass="docutils literal notranslate"><spanclass="pre">text</span></code> input/outputcommand.</p>
</div>
<divclass="section"id="web-client">
<h3>Web client<aclass="headerlink"href="#web-client"title="Permalink to this headline">¶</a></h3>
<p>Our web client uses pure JSON structures for all its communication, including <codeclass="docutils literal notranslate"><spanclass="pre">text</span></code>. This maps directly to the Evennia internal output/inputcommand, including eventual empty args/kwargs. So the same example <codeclass="docutils literal notranslate"><spanclass="pre">("cmdname",</span><spanclass="pre">("arg",),</span><spanclass="pre">{})</span></code> will be sent/received as a valid JSON structure</p>