forked from cory/tildefriends
Try to clean up some websocket noise, and try harder to not duplicate connections.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3647 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -548,15 +548,22 @@ function message(event) {
|
||||
function reconnect(path) {
|
||||
let oldSocket = gSocket;
|
||||
gSocket = null
|
||||
oldSocket.onclose = function() {}
|
||||
oldSocket.onmessage = function() {}
|
||||
oldSocket.onopen = null;
|
||||
oldSocket.onclose = null;
|
||||
oldSocket.onmessage = null;
|
||||
oldSocket.close();
|
||||
connectSocket(path);
|
||||
}
|
||||
|
||||
function connectSocket(path) {
|
||||
if (!gSocket || gSocket.readyState == gSocket.CLOSED) {
|
||||
setStatusMessage("Connecting...", kStatusColor, true);
|
||||
if (!gSocket || gSocket.readyState != gSocket.OPEN) {
|
||||
if (gSocket) {
|
||||
gSocket.onopen = null;
|
||||
gSocket.onclose = null;
|
||||
gSocket.onmessage = null;
|
||||
gSocket.close();
|
||||
}
|
||||
setStatusMessage("Connecting...", kStatusColor, false);
|
||||
gSocket = new WebSocket(
|
||||
(window.location.protocol == "https:" ? "wss://" : "ws://")
|
||||
+ window.location.hostname
|
||||
|
Reference in New Issue
Block a user