make webclient pages unique
This commit is contained in:
parent
85a0b0940d
commit
9a35b269cd
2 changed files with 16 additions and 5 deletions
|
|
@ -220,6 +220,7 @@ An "emitter" object must have a function
|
||||||
var websocket = null;
|
var websocket = null;
|
||||||
var wsurl = window.wsurl;
|
var wsurl = window.wsurl;
|
||||||
var csessid = window.csessid;
|
var csessid = window.csessid;
|
||||||
|
var cuid = window.cuid;
|
||||||
|
|
||||||
var connect = function() {
|
var connect = function() {
|
||||||
if (websocket && websocket.readyState != websocket.CLOSED) {
|
if (websocket && websocket.readyState != websocket.CLOSED) {
|
||||||
|
|
@ -227,7 +228,7 @@ An "emitter" object must have a function
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Important - we pass csessid tacked on the url
|
// Important - we pass csessid tacked on the url
|
||||||
websocket = new WebSocket(wsurl + '?' + csessid + '&' + browser);
|
websocket = new WebSocket(wsurl + '?' + csessid + '&' + cuid + '&' + browser);
|
||||||
|
|
||||||
// Handle Websocket open event
|
// Handle Websocket open event
|
||||||
websocket.onopen = function (event) {
|
websocket.onopen = function (event) {
|
||||||
|
|
@ -304,13 +305,14 @@ An "emitter" object must have a function
|
||||||
var stop_polling = false;
|
var stop_polling = false;
|
||||||
var is_closing = false;
|
var is_closing = false;
|
||||||
var csessid = window.csessid;
|
var csessid = window.csessid;
|
||||||
|
var cuid = window.cuid;
|
||||||
|
|
||||||
// initialize connection, send csessid
|
// initialize connection, send csessid
|
||||||
var init = function() {
|
var init = function() {
|
||||||
$.ajax({type: "POST", url: "/webclientdata",
|
$.ajax({type: "POST", url: "/webclientdata",
|
||||||
async: true, cache: false, timeout: 50000,
|
async: true, cache: false, timeout: 50000,
|
||||||
datatype: "json",
|
datatype: "json",
|
||||||
data: {mode: "init", csessid: csessid, browserstr: browser},
|
data: {mode: "init", csessid: csessid, cuid: cuid, browserstr: browser},
|
||||||
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
open = true;
|
open = true;
|
||||||
|
|
@ -336,7 +338,7 @@ An "emitter" object must have a function
|
||||||
async: true, cache: false, timeout: 30000,
|
async: true, cache: false, timeout: 30000,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: {mode: inmode == null ? 'input' : inmode,
|
data: {mode: inmode == null ? 'input' : inmode,
|
||||||
data: JSON.stringify(data), 'csessid': csessid},
|
data: JSON.stringify(data), 'csessid': csessid, 'cuid': cuid},
|
||||||
success: function(req, stat, err) {
|
success: function(req, stat, err) {
|
||||||
stop_polling = false;
|
stop_polling = false;
|
||||||
},
|
},
|
||||||
|
|
@ -356,7 +358,7 @@ An "emitter" object must have a function
|
||||||
$.ajax({type: "POST", url: "/webclientdata",
|
$.ajax({type: "POST", url: "/webclientdata",
|
||||||
async: true, cache: false, timeout: 60000,
|
async: true, cache: false, timeout: 60000,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: {mode: 'receive', 'csessid': csessid},
|
data: {mode: 'receive', 'csessid': csessid, 'cuid': cuid},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
// log("ajax data received:", data);
|
// log("ajax data received:", data);
|
||||||
if (data[0] === "ajax_keepalive") {
|
if (data[0] === "ajax_keepalive") {
|
||||||
|
|
@ -411,7 +413,7 @@ An "emitter" object must have a function
|
||||||
cache: false,
|
cache: false,
|
||||||
timeout: 50000,
|
timeout: 50000,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: {mode: 'close', 'csessid': csessid},
|
data: {mode: 'close', 'csessid': csessid, 'cuid': cuid},
|
||||||
|
|
||||||
success: function(data){
|
success: function(data){
|
||||||
is_closing = false;
|
is_closing = false;
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,15 @@ JQuery available.
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- Generate a low-quality UID to uniquely identify client tabs -->
|
||||||
|
<script language="javascript" type="text/javascript">
|
||||||
|
function generateUID() {
|
||||||
|
return Math.random().toString(36).substring(2, 15) +
|
||||||
|
Math.random().toString(36).substring(2, 15);
|
||||||
|
}
|
||||||
|
var cuid = generateUID();
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- Set up Websocket url and load the evennia.js library-->
|
<!-- Set up Websocket url and load the evennia.js library-->
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
{% if websocket_enabled %}
|
{% if websocket_enabled %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue