A rudimentary OOB input parser from the webclient, for testing.

This commit is contained in:
Griatch 2016-04-06 21:00:16 +02:00
parent 4ccd78a97e
commit 4acea5a20d
3 changed files with 17 additions and 7 deletions

View file

@ -32,7 +32,6 @@ import json
from twisted.internet.protocol import Protocol
from django.conf import settings
from evennia.server.session import Session
from evennia.utils.logger import log_trace
from evennia.utils.utils import to_str
from evennia.utils.ansi import parse_ansi
from evennia.utils.text2html import parse_html
@ -124,6 +123,7 @@ class WebSocketClient(Protocol, Session):
if "websocket_close" in kwargs:
self.disconnect()
return
print "websocket in:", kwargs
self.sessionhandler.data_in(self, **kwargs)
def data_out(self, **kwargs):

View file

@ -14,8 +14,8 @@ All messages is a valid JSON array on single form:
["cmdname", args, kwargs],
where kwargs is a JSON object that will be used as argument to call
the cmdname function.
where args is an JSON array and kwargs is a JSON object that will be
used as argument to call the cmdname function.
This library makes the "Evennia" object available. It has the
following official functions:

View file

@ -57,10 +57,20 @@ var input_history = function() {
// Grab text from inputline and send to Evennia
function doSendText() {
inputfield = $("#inputfield");
outtext = inputfield.val();
input_history.add(outtext);
inputfield.val("");
Evennia.msg("text", [outtext], {});
var outtext = inputfield.val();
if (outtext.length > 7 && outtext.substr(0, 7) == "##send ") {
// send a specific oob instruction
outtext = outtext.slice(7);
var arr = outtext.split(' ');
var cmdname = arr.shift();
var kwargs = arr.join(' ');
log(cmdname, kwargs);
Evennia.msg(cmdname, [], JSON.parse(kwargs));
} else {
input_history.add(outtext);
inputfield.val("");
Evennia.msg("text", [outtext], {});
}
}
// catch all keyboard input, handle special chars