mirror of https://github.com/calzoneman/sync.git
Change alt socket to socketio xhr-polling
This commit is contained in:
parent
07795feffa
commit
5a5016fd79
|
@ -1001,23 +1001,17 @@ setupCallbacks = function() {
|
|||
}
|
||||
}
|
||||
|
||||
if(USEROPTS.altsocket) {
|
||||
socket = new NotWebsocket();
|
||||
setupCallbacks();
|
||||
}
|
||||
else {
|
||||
$.getScript(IO_URL+"/socket.io/socket.io.js", function() {
|
||||
try {
|
||||
if(NO_WEBSOCKETS) {
|
||||
var i = io.transports.indexOf("websocket");
|
||||
if(i >= 0)
|
||||
io.transports.splice(i, 1);
|
||||
}
|
||||
socket = io.connect(IO_URL);
|
||||
setupCallbacks();
|
||||
$.getScript(IO_URL+"/socket.io/socket.io.js", function() {
|
||||
try {
|
||||
if(NO_WEBSOCKETS) {
|
||||
var i = io.transports.indexOf("websocket");
|
||||
if(i >= 0)
|
||||
io.transports.splice(i, 1);
|
||||
}
|
||||
catch(e) {
|
||||
Callbacks.disconnect();
|
||||
}
|
||||
});
|
||||
}
|
||||
socket = io.connect(IO_URL);
|
||||
setupCallbacks();
|
||||
}
|
||||
catch(e) {
|
||||
Callbacks.disconnect();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -21,6 +21,7 @@ var CLIENT = {
|
|||
text: ""
|
||||
}
|
||||
};
|
||||
var SUPERADMIN = false;
|
||||
|
||||
var CHANNEL = {
|
||||
opts: {},
|
||||
|
@ -113,6 +114,8 @@ var USEROPTS = {
|
|||
ignore_channeljs : getOrDefault("ignore_channeljs", false)
|
||||
};
|
||||
|
||||
var NO_WEBSOCKETS = USEROPTS.altsocket;
|
||||
|
||||
var Rank = {
|
||||
Guest: 0,
|
||||
Member: 1,
|
||||
|
|
|
@ -11,4 +11,3 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|||
|
||||
var IO_URL = "http://localhost:1337";
|
||||
var WEB_URL = "http://localhost:8080";
|
||||
var NO_WEBSOCKETS = false;
|
||||
|
|
|
@ -478,7 +478,7 @@ function showOptionsMenu() {
|
|||
addOption("Send Button", sendbtncontainer);
|
||||
|
||||
var altsocketcontainer = $("<label/>").addClass("checkbox")
|
||||
.text("Use alternative socket connection");
|
||||
.text("Use alternative socket connection (requires refresh)");
|
||||
var altsocket = $("<input/>").attr("type", "checkbox")
|
||||
.appendTo(altsocketcontainer);
|
||||
altsocket.prop("checked", USEROPTS.altsocket);
|
||||
|
@ -594,24 +594,6 @@ function applyOpts() {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(USEROPTS.altsocket) {
|
||||
if(!socket.nws) {
|
||||
if(socket && socket.disconnect)
|
||||
socket.disconnect();
|
||||
socket = new NotWebsocket();
|
||||
setupCallbacks();
|
||||
}
|
||||
}
|
||||
// Switch from NotWebsocket => Socket.io
|
||||
else if(socket && typeof socket.poll !== "undefined") {
|
||||
try {
|
||||
socket = io.connect(IO_URL);
|
||||
setupCallbacks();
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
applyOpts();
|
||||
|
|
Loading…
Reference in New Issue