...
|
...
|
@@ -9,6 +9,7 @@ var param, |
|
|
servers,
|
|
|
socket,
|
|
|
server,
|
|
|
sendFailCallback,
|
|
|
conversationMessage;
|
|
|
|
|
|
function _randomServer() {
|
...
|
...
|
@@ -40,6 +41,10 @@ function socketInit(options) { |
|
|
socket.onclose = options.onClose || function() {
|
|
|
console.log('websocket is closed');
|
|
|
};
|
|
|
socket.onerror = options.onError || function() {
|
|
|
console.log('websocket meet error');
|
|
|
};
|
|
|
sendFailCallback = options.sendFailCallback || $.noop;
|
|
|
} else {
|
|
|
console.log('websocket is not support');
|
|
|
}
|
...
|
...
|
@@ -57,6 +62,7 @@ function sendMsg(msg) { |
|
|
console.log('websocket send: ', JSON.parse(msg));
|
|
|
socket.send(msg);
|
|
|
} else {
|
|
|
sendFailCallback();
|
|
|
console.log('The socket is not open.');
|
|
|
}
|
|
|
}
|
...
|
...
|
|