mirror of
https://github.com/evennia/evennia.git
synced 2026-03-31 13:07:16 +02:00
Changed how the webclient looks up the webcocket_url. This auto-lookups the url while still respecting a custom given settings.WEBSOCKET_CLIENT_URL (for proxy setups?). This means settings.WEBSOCKET_CLIENT_URL is now defaulting to None. Resolves #806.
This commit is contained in:
parent
27bde5129b
commit
5429ede5f7
3 changed files with 15 additions and 6 deletions
|
|
@ -71,9 +71,12 @@ WEBSOCKET_CLIENT_ENABLED = True
|
|||
WEBSOCKET_CLIENT_PORT = 8001
|
||||
# Interface addresses to listen to. If 0.0.0.0, listen to all. Use :: for IPv6.
|
||||
WEBSOCKET_CLIENT_INTERFACE = '0.0.0.0'
|
||||
# Actual URL for webclient component to reach the websocket.
|
||||
# The WEBSOCKET_CLIENT_PORT will be automatically appended to this URL.
|
||||
WEBSOCKET_CLIENT_URL = "ws://localhost"
|
||||
# Actual URL for webclient component to reach the websocket. You only need
|
||||
# to set this if you know you need it, like using some sort of proxy setup.
|
||||
# If given it must be on the form "ws://hostname" (WEBSOCKET_CLIENT_PORT will
|
||||
# be automatically appended). If left at None, the client will itself
|
||||
# figure out this url based on the server's hostname.
|
||||
WEBSOCKET_CLIENT_URL = None
|
||||
# Activate SSH protocol communication (SecureShell)
|
||||
SSH_ENABLED = False
|
||||
# Ports to use for SSH
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ WEBSITE = ['Flatpages', 'News', 'Sites']
|
|||
# The main context processor function
|
||||
WEBCLIENT_ENABLED = settings.WEBCLIENT_ENABLED
|
||||
WEBSOCKET_CLIENT_ENABLED = settings.WEBSOCKET_CLIENT_ENABLED
|
||||
WSURL = "%s:%s" % (settings.WEBSOCKET_CLIENT_URL, settings.WEBSOCKET_CLIENT_PORT)
|
||||
WEBSOCKET_PORT = settings.WEBSOCKET_CLIENT_PORT
|
||||
WEBSOCKET_URL = settings.WEBSOCKET_CLIENT_URL
|
||||
|
||||
def general_context(request):
|
||||
"""
|
||||
|
|
@ -48,5 +49,6 @@ def general_context(request):
|
|||
'evennia_websiteapps':WEBSITE,
|
||||
"webclient_enabled" : WEBCLIENT_ENABLED,
|
||||
"websocket_enabled" : WEBSOCKET_CLIENT_ENABLED,
|
||||
"websocket_url" : WSURL
|
||||
"websocket_port" : WEBSOCKET_PORT,
|
||||
"websocket_url" : WEBSOCKET_URL
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,11 @@
|
|||
<script language="javascript" type="text/javascript">
|
||||
if ("WebSocket" in window) {
|
||||
<!-- Importing the Evennia websocket webclient component (requires jQuery) -->
|
||||
var wsurl = "{{websocket_url}}";
|
||||
{% if websocket_url %}
|
||||
var wsurl = "{{websocket_url}}:{{websocket_port}}";
|
||||
{% else %}
|
||||
var wsurl = "ws://" + this.location.hostname + ":{{websocket_port}}";
|
||||
{% endif %}
|
||||
document.write("\<script src=\"{% static "webclient/js/evennia_websocket_webclient.js" %}\" type=\"text/javascript\" charset=\"utf-8\"\>\</script\>")}
|
||||
else {
|
||||
<!-- No websocket support in browser. Importing the Evennia ajax webclient component (requires jQuery) -->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue