A rudimentary OOB input parser from the webclient, for testing.
This commit is contained in:
parent
4ccd78a97e
commit
4acea5a20d
3 changed files with 17 additions and 7 deletions
|
|
@ -32,7 +32,6 @@ import json
|
||||||
from twisted.internet.protocol import Protocol
|
from twisted.internet.protocol import Protocol
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from evennia.server.session import Session
|
from evennia.server.session import Session
|
||||||
from evennia.utils.logger import log_trace
|
|
||||||
from evennia.utils.utils import to_str
|
from evennia.utils.utils import to_str
|
||||||
from evennia.utils.ansi import parse_ansi
|
from evennia.utils.ansi import parse_ansi
|
||||||
from evennia.utils.text2html import parse_html
|
from evennia.utils.text2html import parse_html
|
||||||
|
|
@ -124,6 +123,7 @@ class WebSocketClient(Protocol, Session):
|
||||||
if "websocket_close" in kwargs:
|
if "websocket_close" in kwargs:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
return
|
return
|
||||||
|
print "websocket in:", kwargs
|
||||||
self.sessionhandler.data_in(self, **kwargs)
|
self.sessionhandler.data_in(self, **kwargs)
|
||||||
|
|
||||||
def data_out(self, **kwargs):
|
def data_out(self, **kwargs):
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ All messages is a valid JSON array on single form:
|
||||||
|
|
||||||
["cmdname", args, kwargs],
|
["cmdname", args, kwargs],
|
||||||
|
|
||||||
where kwargs is a JSON object that will be used as argument to call
|
where args is an JSON array and kwargs is a JSON object that will be
|
||||||
the cmdname function.
|
used as argument to call the cmdname function.
|
||||||
|
|
||||||
This library makes the "Evennia" object available. It has the
|
This library makes the "Evennia" object available. It has the
|
||||||
following official functions:
|
following official functions:
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,20 @@ var input_history = function() {
|
||||||
// Grab text from inputline and send to Evennia
|
// Grab text from inputline and send to Evennia
|
||||||
function doSendText() {
|
function doSendText() {
|
||||||
inputfield = $("#inputfield");
|
inputfield = $("#inputfield");
|
||||||
outtext = inputfield.val();
|
var outtext = inputfield.val();
|
||||||
input_history.add(outtext);
|
if (outtext.length > 7 && outtext.substr(0, 7) == "##send ") {
|
||||||
inputfield.val("");
|
// send a specific oob instruction
|
||||||
Evennia.msg("text", [outtext], {});
|
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
|
// catch all keyboard input, handle special chars
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue