added modules for work with socket.io

This commit is contained in:
coderaiser 2012-09-19 04:15:00 -04:00
parent 000fc9b6a3
commit 2f5178d4e7
3 changed files with 65 additions and 17 deletions

0
lib/client/Untitled Normal file
View file

View 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');
}
});
})();