mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-11 16:08:24 -05:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3134940ed6 | ||
|
|
0f783bc06a | ||
|
|
dd3d829173 | ||
|
|
fbce6379a5 |
11
README.md
11
README.md
@@ -36,12 +36,15 @@ By default, the server will intercept requests that contain `socket.io` in the p
|
||||
|
||||
On the client side, you should use the [Socket.IO client](https://github.com/LearnBoost/Socket.IO) to connect.
|
||||
|
||||
## Checking out
|
||||
## Notes
|
||||
|
||||
After cloning the repository, remember to run
|
||||
IMPORTANT! When checking out the git repo, make sure to include the submodules. One way to do it is:
|
||||
|
||||
git submodule init
|
||||
git submodule update
|
||||
git clone [repo] --recursive
|
||||
|
||||
Another, once cloned
|
||||
|
||||
git submodule update --init --recursive
|
||||
|
||||
## Demo
|
||||
|
||||
|
||||
@@ -8,12 +8,21 @@ this['htmlfile'] = Client.extend({
|
||||
switch (req.method){
|
||||
case 'GET':
|
||||
this.__super__(req, res);
|
||||
this.request.connection.addListener('end', function(){ self._onClose(); });
|
||||
this.response.useChunkedEncodingByDefault = false;
|
||||
this.request.connection.addListener('close', function(){ self._onClose(); });
|
||||
this.response.useChunkedEncodingByDefault = true;
|
||||
this.response.shouldKeepAlive = true;
|
||||
this.response.writeHead(200, { 'Content-type': 'text/html' });
|
||||
this.response.writeHead(200, {
|
||||
'Content-Type': 'text/html',
|
||||
'Connection': 'keep-alive',
|
||||
'Transfer-Encoding': 'chunked'
|
||||
});
|
||||
this.response.write('<html><body>' + new Array(244).join(' '));
|
||||
this.response.flush();
|
||||
this._payload();
|
||||
setInterval(function(){
|
||||
self.response.write('<!-- heartbeat -->');
|
||||
self.response.flush();
|
||||
}, 1000);
|
||||
break;
|
||||
|
||||
case 'POST':
|
||||
@@ -24,7 +33,7 @@ this['htmlfile'] = Client.extend({
|
||||
try {
|
||||
var msg = qs.parse(body);
|
||||
self._onMessage(msg.data);
|
||||
} catch(e){}
|
||||
} catch(e){}
|
||||
res.writeHead(200);
|
||||
res.write('ok');
|
||||
res.end();
|
||||
@@ -34,8 +43,8 @@ this['htmlfile'] = Client.extend({
|
||||
},
|
||||
|
||||
_write: function(message){
|
||||
// not sure if this is enough escaping. looks lousy
|
||||
this.response.write("<script>parent.callback('"+ message.replace(/'/, "\'") +"')</script>");
|
||||
this.response.write('<script>parent.s._('+ message +', document);</script>');
|
||||
this.response.flush();
|
||||
}
|
||||
|
||||
});
|
||||
@@ -13,10 +13,10 @@ this['xhr-polling'] = Client.extend({
|
||||
var self = this, body = '';
|
||||
switch (req.method){
|
||||
case 'GET':
|
||||
this.__super__(req, res);
|
||||
this.__super__(req, res);
|
||||
this._closeTimeout = setTimeout(function(){
|
||||
self._write('');
|
||||
}, this.options.duration);
|
||||
}, this.options.duration);
|
||||
this._payload();
|
||||
break;
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// Copyright (c) 2006-2009 Valerio Proietti, <http://mad4milk.net/>
|
||||
|
||||
var clone = this.clone = function(item){
|
||||
var clone;
|
||||
var cloned;
|
||||
if (item instanceof Array){
|
||||
clone = [];
|
||||
for (var i = 0; i < item.length; i++) clone[i] = clone(item[i]);
|
||||
return clone;
|
||||
cloned = [];
|
||||
for (var i = 0; i < item.length; i++) cloned[i] = clone(item[i]);
|
||||
return cloned;
|
||||
} else if (typeof item == 'object') {
|
||||
clone = {};
|
||||
for (var key in object) clone[key] = clone(object[key]);
|
||||
return clone;
|
||||
cloned = {};
|
||||
for (var key in object) cloned[key] = clone(object[key]);
|
||||
return cloned;
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
@@ -35,4 +35,4 @@ this.merge = function(source, k, v){
|
||||
for (var key in object) mergeOne(source, key, object[key]);
|
||||
}
|
||||
return source;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
document.getElementById('text').value = '';
|
||||
}
|
||||
|
||||
var socket = new io.Socket('localhost', {rememberTransport: false, port: 8080});
|
||||
var socket = new io.Socket(null, {rememberTransport: false, port: 8080});
|
||||
socket.connect();
|
||||
socket.addEvent('message', function(data){
|
||||
var obj = JSON.parse(data);
|
||||
|
||||
Submodule test/client updated: 1e0e9fb87d...d643e6029c
Reference in New Issue
Block a user