Added close-handlers to websocket and did some other cleanup.
This commit is contained in:
parent
166189a7a5
commit
b6642cdfe9
4 changed files with 20 additions and 5 deletions
|
|
@ -231,7 +231,10 @@ An "emitter" object must have a function
|
|||
websocket.send(JSON.stringify(data));
|
||||
};
|
||||
websocket.close = function() {
|
||||
// close connection.
|
||||
// tell the server this connection is closing (usually
|
||||
// tied to when the client window is closed). This
|
||||
// Makes use of a websocket-protocol specific instruction.
|
||||
websocket.send(JSON.stringify(["websocket_close", [], {}]));
|
||||
}
|
||||
return websocket;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -138,6 +138,9 @@ $(document).ready(function() {
|
|||
Evennia.emitter.on("text", onText);
|
||||
Evennia.emitter.on("prompt", onPrompt);
|
||||
Evennia.emitter.on("default", onDefault);
|
||||
// Event when closing window (have to have Evennia initialized)
|
||||
$(window).bind("beforeunload", Evennia.connection.close);
|
||||
|
||||
doWindowResize();
|
||||
|
||||
// set an idle timer to send idle every 3 minutes,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue