mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 17:05:17 +00:00
added modules for work with socket.io
This commit is contained in:
parent
000fc9b6a3
commit
2f5178d4e7
3 changed files with 65 additions and 17 deletions
0
lib/client/Untitled
Normal file
0
lib/client/Untitled
Normal file
|
|
@ -1,17 +1,29 @@
|
|||
/* module make possible connectoin thrue socket.io on a client */
|
||||
var CloudCommander, io;
|
||||
var CloudCommander, io, socket;
|
||||
(function(){
|
||||
"use strict";
|
||||
var Util = CloudCommander.Util;
|
||||
|
||||
Util.jsload("http://localhost:31337/socket.io/lib/socket.io.js", function(){
|
||||
var socket = io.connect('http://localhost:31337/');
|
||||
socket.on('connect', function () {
|
||||
socket.send('hi');
|
||||
Util.jsload("http://localhost:31337/socket.io/lib/socket.io.js", {
|
||||
onload : function(){
|
||||
socket = io.connect(document.location.hostname);
|
||||
|
||||
socket.on('connect', function () {
|
||||
console.log('socket connected');
|
||||
});
|
||||
|
||||
socket.on('message', function (msg) {
|
||||
console.log(msg);
|
||||
});
|
||||
|
||||
socket.on('disconnect', function () {
|
||||
console.log('socket disconected');
|
||||
});
|
||||
},
|
||||
|
||||
socket.on('message', function (msg) {
|
||||
console.log(msg);
|
||||
});
|
||||
});
|
||||
onerror : function(){
|
||||
console.log('could not connect to socket.io\n'+
|
||||
'npm i socket.io');
|
||||
}
|
||||
});
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue