Implemented an AJAX keepalive from the Evennia side to make sure a dead AJAX connection (commonly if the user closes the window/browser without properly logging out), will eventually time out and log off the Player. Resolves #951.
This commit is contained in:
parent
d5b3b59eb7
commit
7e62f02f0a
2 changed files with 77 additions and 18 deletions
|
|
@ -195,7 +195,6 @@ An "emitter" object must have a function
|
|||
//
|
||||
var WebsocketConnection = function () {
|
||||
log("Trying websocket ...");
|
||||
wsurl = "ws://blah";
|
||||
var open = false;
|
||||
var websocket = new WebSocket(wsurl);
|
||||
// Handle Websocket open event
|
||||
|
|
@ -275,11 +274,12 @@ An "emitter" object must have a function
|
|||
};
|
||||
|
||||
// Send Client -> Evennia. Called by Evennia.msg
|
||||
var msg = function(data) {
|
||||
var msg = function(data, inmode) {
|
||||
$.ajax({type: "POST", url: "/webclientdata",
|
||||
async: true, cache: false, timeout: 30000,
|
||||
dataType: "json",
|
||||
data: {mode:'input', data: JSON.stringify(data), 'suid': client_hash},
|
||||
data: {mode: inmode == null ? 'input' : inmode,
|
||||
data: JSON.stringify(data), 'suid': client_hash},
|
||||
success: function(req, stat, err) {},
|
||||
error: function(req, stat, err) {
|
||||
Evennia.emit("connection_error", ["AJAX/COMET send error"], err);
|
||||
|
|
@ -298,8 +298,14 @@ An "emitter" object must have a function
|
|||
dataType: "json",
|
||||
data: {mode: 'receive', 'suid': client_hash},
|
||||
success: function(data) {
|
||||
log("ajax data received:", data);
|
||||
Evennia.emit(data[0], data[1], data[2]);
|
||||
// log("ajax data received:", data);
|
||||
if (data[0] === "ajax_keepalive") {
|
||||
// special ajax keepalive check - return immediately
|
||||
msg("", "keepalive");
|
||||
} else {
|
||||
// not a keepalive
|
||||
Evennia.emit(data[0], data[1], data[2]);
|
||||
}
|
||||
poll(); // immiately start a new request
|
||||
},
|
||||
error: function(req, stat, err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue