Ajax client classes are now customizable.
This commit is contained in:
parent
e2a7c54e24
commit
d825994230
3 changed files with 16 additions and 5 deletions
|
|
@ -191,9 +191,8 @@ class EvenniaPortalService(MultiService):
|
||||||
webclientstr = ""
|
webclientstr = ""
|
||||||
if settings.WEBCLIENT_ENABLED:
|
if settings.WEBCLIENT_ENABLED:
|
||||||
# create ajax client processes at /webclientdata
|
# create ajax client processes at /webclientdata
|
||||||
from evennia.server.portal import webclient_ajax
|
ajax_class = class_from_module(settings.AJAX_CLIENT_CLASS)
|
||||||
|
ajax_webclient = ajax_class()
|
||||||
ajax_webclient = webclient_ajax.AjaxWebClient()
|
|
||||||
ajax_webclient.sessionhandler = evennia.PORTAL_SESSION_HANDLER
|
ajax_webclient.sessionhandler = evennia.PORTAL_SESSION_HANDLER
|
||||||
web_root.putChild(b"webclientdata", ajax_webclient)
|
web_root.putChild(b"webclientdata", ajax_webclient)
|
||||||
webclientstr = "webclient (ajax only)"
|
webclientstr = "webclient (ajax only)"
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ from evennia.server import session
|
||||||
from evennia.utils import utils
|
from evennia.utils import utils
|
||||||
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
|
||||||
from evennia.utils.utils import to_bytes, ip_from_request
|
from evennia.utils.utils import to_bytes, class_from_module, ip_from_request
|
||||||
|
|
||||||
_CLIENT_SESSIONS = utils.mod_import(settings.SESSION_ENGINE).SessionStore
|
_CLIENT_SESSIONS = utils.mod_import(settings.SESSION_ENGINE).SessionStore
|
||||||
_RE_SCREENREADER_REGEX = re.compile(
|
_RE_SCREENREADER_REGEX = re.compile(
|
||||||
|
|
@ -70,6 +70,8 @@ class AjaxWebClient(resource.Resource):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
client_protocol = class_from_module(settings.AJAX_PROTOCOL_CLASS)
|
||||||
|
|
||||||
isLeaf = True
|
isLeaf = True
|
||||||
allowedMethods = ("POST",)
|
allowedMethods = ("POST",)
|
||||||
|
|
||||||
|
|
@ -205,7 +207,7 @@ class AjaxWebClient(resource.Resource):
|
||||||
request.getHost().port,
|
request.getHost().port,
|
||||||
)
|
)
|
||||||
|
|
||||||
sess = AjaxWebClientSession()
|
sess = self.client_protocol()
|
||||||
sess.client = self
|
sess.client = self
|
||||||
sess.init_session("ajax/comet", remote_addr, self.sessionhandler)
|
sess.init_session("ajax/comet", remote_addr, self.sessionhandler)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1177,6 +1177,16 @@ SSL_PROTOCOL_CLASS = "evennia.server.portal.ssl.SSLProtocol"
|
||||||
# for all webclient connections.
|
# for all webclient connections.
|
||||||
WEBSOCKET_PROTOCOL_CLASS = "evennia.server.portal.webclient.WebSocketClient"
|
WEBSOCKET_PROTOCOL_CLASS = "evennia.server.portal.webclient.WebSocketClient"
|
||||||
|
|
||||||
|
# Ajax Web Client classes. Evennia uses AJAX as a fallback for the webclient by
|
||||||
|
# default. AJAX may in general be more useful for mobile clients as it's
|
||||||
|
# resilient to IP address changes.
|
||||||
|
|
||||||
|
# The Ajax Client Class is used to manage all AJAX sessions.
|
||||||
|
AJAX_CLIENT_CLASS = "evennia.server.webclient.ajax.AjaxWebClient"
|
||||||
|
|
||||||
|
# Ajax Protocol Class is used for all AJAX client connections.
|
||||||
|
AJAX_PROTOCOL_CLASS = "evennia.server.webclient_ajax.AjaxWebClientSession"
|
||||||
|
|
||||||
# Protocol for the SSH interface. This inherits from BASE_SESSION_CLASS.
|
# Protocol for the SSH interface. This inherits from BASE_SESSION_CLASS.
|
||||||
SSH_PROTOCOL_CLASS = "evennia.server.portal.ssh.SshProtocol"
|
SSH_PROTOCOL_CLASS = "evennia.server.portal.ssh.SshProtocol"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue