mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
from now on disconnecting - trying to do new connection
This commit is contained in:
parent
5e152c6b37
commit
272d5a22fd
2 changed files with 25 additions and 19 deletions
|
|
@ -64,6 +64,7 @@ disabled in browsers.
|
|||
|
||||
* Added ability convert charset from win to unicode on win32.
|
||||
|
||||
* From now on disconnecting - trying to do new connection.
|
||||
|
||||
2012.08.24, Version 0.1.6
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,37 @@
|
|||
/* module make possible connectoin thrue socket.io on a client */
|
||||
var CloudCommander, io, socket;
|
||||
var CloudCommander, io;
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
var cloudcmd = CloudCommander,
|
||||
Util = cloudcmd.Util,
|
||||
Messages = [],
|
||||
socket,
|
||||
JqueryTerminal = cloudcmd.Terminal.JqueryTerminal;
|
||||
|
||||
|
||||
var socketConfig_f = function(){
|
||||
socket = io.connect(document.location.hostname);
|
||||
|
||||
cloudcmd.Socket = socket;
|
||||
|
||||
socket.on('connect', function () {
|
||||
outToTerminal('socket connected');
|
||||
});
|
||||
|
||||
socket.on('message', function (msg) {
|
||||
outToTerminal(msg);
|
||||
|
||||
});
|
||||
|
||||
socket.on('disconnect', function () {
|
||||
outToTerminal('socket disconected');
|
||||
socketConfig_f();
|
||||
});
|
||||
};
|
||||
|
||||
Util.jsload("/socket.io/lib/socket.io.js", {
|
||||
onload : function(){
|
||||
socket = io.connect(document.location.hostname);
|
||||
|
||||
cloudcmd.Socket = socket;
|
||||
|
||||
socket.on('connect', function () {
|
||||
outToTerminal('socket connected');
|
||||
});
|
||||
|
||||
socket.on('message', function (msg) {
|
||||
outToTerminal(msg);
|
||||
|
||||
});
|
||||
|
||||
socket.on('disconnect', function () {
|
||||
outToTerminal('socket disconected');
|
||||
});
|
||||
},
|
||||
onload : socketConfig_f,
|
||||
|
||||
onerror : function(){
|
||||
console.log('could not connect to socket.io\n'+
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue