Permalink
Browse files

Builder now puts a notice at the top of the file

Fixed indentation
  • Loading branch information...
1 parent 16e1f35 commit 5cebe02f5d395c3c6068bb317b2e782a077b3726 @rauchg rauchg committed Mar 19, 2010
View
49 build.js 100644 → 100755
@@ -14,30 +14,31 @@
*/
var fs = require('fs'),
- sys = require('sys'),
- files = [
- 'io.js',
- 'util/util.js',
- 'util/object.js',
- 'util/array.js',
- 'util/options.js',
- 'util/events.js',
- 'util/json.js',
- 'util/oo.js',
- 'transport.js',
- 'transports/xhr.js',
- 'transports/websocket.js',
- 'transports/flashsocket.js',
- 'transports/htmlfile.js',
- 'transports/server-events.js',
- 'transports/xhr-multipart.js',
- 'transports/xhr-polling.js',
- 'socket.js',
- 'vendor/web-socket-js/swfobject.js',
- 'vendor/web-socket-js/FABridge.js',
- 'vendor/web-socket-js/web_socket.js'
- ],
- content = '';
+ sys = require('sys'),
+ socket = require('./lib/io'),
+ files = [
+ 'io.js',
+ 'util/util.js',
+ 'util/object.js',
+ 'util/array.js',
+ 'util/options.js',
+ 'util/events.js',
+ 'util/json.js',
+ 'util/oo.js',
+ 'transport.js',
+ 'transports/xhr.js',
+ 'transports/websocket.js',
+ 'transports/flashsocket.js',
+ 'transports/htmlfile.js',
+ 'transports/server-events.js',
+ 'transports/xhr-multipart.js',
+ 'transports/xhr-polling.js',
+ 'socket.js',
+ 'vendor/web-socket-js/swfobject.js',
+ 'vendor/web-socket-js/FABridge.js',
+ 'vendor/web-socket-js/web_socket.js'
+ ],
+ content = "/** Socket.IO "+ socket.io.version +" - Built with build.js */\n";
sys.log('Reading files…');
View
@@ -7,7 +7,7 @@
*/
this.io = {
- version: 0.1,
+ version: '0.1',
setPath: function(path){
this.path = path;
View
@@ -8,86 +8,86 @@
io.Socket = ioClass({
- include: [io.util.Events, io.util.Options],
+ include: [io.util.Events, io.util.Options],
- options: {
- secure: false,
+ options: {
+ secure: false,
document: document,
- resource: 'socket.io',
- transports: ['websocket', 'server-events', 'flashsocket', 'htmlfile', 'xhr-multipart', 'xhr-polling'],
- transportOptions: {},
+ resource: 'socket.io',
+ transports: ['websocket', 'server-events', 'flashsocket', 'htmlfile', 'xhr-multipart', 'xhr-polling'],
+ transportOptions: {},
rememberTransport: true
- },
+ },
- init: function(host, options){
- this.host = host;
- this.setOptions(options);
- this.connected = false;
- this.connecting = false;
- this.transport = this.getTransport();
- if (!this.transport && 'console' in window) console.error('No transport available');
- },
+ init: function(host, options){
+ this.host = host;
+ this.setOptions(options);
+ this.connected = false;
+ this.connecting = false;
+ this.transport = this.getTransport();
+ if (!this.transport && 'console' in window) console.error('No transport available');
+ },
- getTransport: function(){
+ getTransport: function(){
var transports = this.options.transports, match;
if (this.options.rememberTransport){
match = this.options.document.cookie.match('(?:^|;)\\s*socket\.io=([^;]*)');
if (match) transports = [decodeURIComponent(match[1])];
}
- for (var i = 0; transport = transports[i]; i++){
- if (io.Transport[transport] && io.Transport[transport].check()){
- return new io.Transport[transport](this, this.options.transportOptions[transport] || {});
- }
- }
- return null;
- },
+ for (var i = 0; transport = transports[i]; i++){
+ if (io.Transport[transport] && io.Transport[transport].check()){
+ return new io.Transport[transport](this, this.options.transportOptions[transport] || {});
+ }
+ }
+ return null;
+ },
- connect: function(){
- if (this.transport && !this.connected && !this.connecting){
- this.connecting = true;
- this.transport.connect();
- }
- return this;
- },
+ connect: function(){
+ if (this.transport && !this.connected && !this.connecting){
+ this.connecting = true;
+ this.transport.connect();
+ }
+ return this;
+ },
+
+ send: function(data){
+ if (!this.transport || !this.transport.connected) return this._queue(data);
+ this.transport.send(JSON.stringify([data]));
+ return this;
+ },
+
+ disconnect: function(){
+ this.transport.disconnect();
+ return this;
+ },
- send: function(data){
- if (!this.transport || !this.transport.connected) return this._queue(data);
- this.transport.send(JSON.stringify([data]));
- return this;
- },
-
- disconnect: function(){
- this.transport.disconnect();
- return this;
- },
-
- _queue: function(message){
- if (!('_queueStack' in this)) this._queueStack = [];
- this._queueStack.push(message);
- return this;
- },
+ _queue: function(message){
+ if (!('_queueStack' in this)) this._queueStack = [];
+ this._queueStack.push(message);
+ return this;
+ },
- _doQueue: function(){
- if (!('_queueStack' in this) || !this._queueStack.length) return this;
+ _doQueue: function(){
+ if (!('_queueStack' in this) || !this._queueStack.length) return this;
this.transport.send(JSON.stringify([].concat(this._queueStack)));
this._queueStack = [];
return this;
- },
-
- _onConnect: function(){
- this.connected = true;
- this.connecting = false;
- this._doQueue();
+ },
+
+ _onConnect: function(){
+ this.connected = true;
+ this.connecting = false;
+ this._doQueue();
if (this.options.rememberTransport) this.options.document.cookie = 'socket.io=' + encodeURIComponent(this.transport.type);
- this.fireEvent('connect');
- },
-
- _onMessage: function(data){
- this.fireEvent('message', data);
- },
+ this.fireEvent('connect');
+ },
+
+ _onMessage: function(data){
+ this.fireEvent('message', data);
+ },
- _onDisconnect: function(){
- this.fireEvent('disconnect');
- }
+ _onDisconnect: function(){
+ this.fireEvent('disconnect');
+ }
});
View
@@ -13,26 +13,26 @@
// abstract
io.Transport = ioClass({
- include: [io.util.Events, io.util.Options],
+ include: [io.util.Events, io.util.Options],
- init: function(base, options){
- this.base = base;
- this.setOptions(options);
- },
+ init: function(base, options){
+ this.base = base;
+ this.setOptions(options);
+ },
- send: function(){
- throw new Error('Missing send() implementation');
- },
+ send: function(){
+ throw new Error('Missing send() implementation');
+ },
- connect: function(){
- throw new Error('Missing connect() implementation');
- },
+ connect: function(){
+ throw new Error('Missing connect() implementation');
+ },
- disconnect: function(){
- throw new Error('Missing disconnect() implementation');
- },
+ disconnect: function(){
+ throw new Error('Missing disconnect() implementation');
+ },
- _onData: function(data){
+ _onData: function(data){
try {
var msgs = json.decode(data);
if (msgs.messages){
@@ -41,16 +41,16 @@
}
}
} catch(e){}
- },
+ },
_onMessage: function(message){
if (!('sessionid' in this)){
try {
var obj = json.decode(message);
- if (obj.sessionid){
- this.sessionid = obj.sessionid;
+ if (obj.sessionid){
+ this.sessionid = obj.sessionid;
this._onConnect();
- }
+ }
} catch(e){}
} else {
this.base._onMessage(message);
@@ -68,14 +68,14 @@
this.base._onDisconnect();
},
- _prepareUrl: function(){
- return (this.base.options.secure ? 'https' : 'http')
- + '://' + this.base.host
- + ':' + this.base.options.port
- + '/' + this.base.options.resource
+ _prepareUrl: function(){
+ return (this.base.options.secure ? 'https' : 'http')
+ + '://' + this.base.host
+ + ':' + this.base.options.port
+ + '/' + this.base.options.resource
+ '/' + this.type
+ (this.sessionid ? ('/' + this.sessionid) : '');
- }
+ }
});
@@ -8,29 +8,29 @@
io.Transport.flashsocket = io.Transport.websocket.extend({
- _onClose: function(){
- if (!this.base.connected){
- // something failed, we might be behind a proxy, so we'll try another transport
- this.base.options.transports.splice(io.util.Array.indexOf(this.base.options.transports, 'flashsocket'), 1);
- this.base.transport = this.base.getTransport();
- this.base.connect();
- return;
- }
- return this.__super__();
- }
+ _onClose: function(){
+ if (!this.base.connected){
+ // something failed, we might be behind a proxy, so we'll try another transport
+ this.base.options.transports.splice(io.util.Array.indexOf(this.base.options.transports, 'flashsocket'), 1);
+ this.base.transport = this.base.getTransport();
+ this.base.connect();
+ return;
+ }
+ return this.__super__();
+ }
});
io.Transport.flashsocket.check = function(){
- if ('navigator' in window && navigator.plugins){
- return !! navigator.plugins['Shockwave Flash'].description;
- }
+ if ('navigator' in window && navigator.plugins){
+ return !! navigator.plugins['Shockwave Flash'].description;
+ }
- if ('ActiveXObject' in window){
- try {
- return !! new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
- } catch (e){}
- }
+ if ('ActiveXObject' in window){
+ try {
+ return !! new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
+ } catch (e){}
+ }
- return false;
+ return false;
};
Oops, something went wrong.

0 comments on commit 5cebe02

Please sign in to comment.