Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Commit c913ec8

Browse files
committed
check thirdparty ws library in to repo
1 parent 537e65e commit c913ec8

19 files changed

Lines changed: 2534 additions & 24 deletions

appshell/node-core/Server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ maxerr: 50, node: true */
3636

3737
var fs = require("fs"),
3838
http = require("http"),
39-
WebSocket = require("ws-deploy"),
39+
WebSocket = require("./thirdparty/ws"),
4040
EventEmitter = require("events").EventEmitter,
4141
Logger = require("./Logger"),
4242
ConnectionManager = require("./ConnectionManager"),

appshell/node-core/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@
44
"description": "Node core for appshell",
55
"main": "Launcher.js",
66
"author": "Joel Brandt <joelrbrandt@gmail.com>",
7-
"license": "MIT",
8-
"dependencies": {
9-
"ws-deploy": "git+https://github.com/joelrbrandt/ws-deploy.git#7a3bdc6b21ebd66d4b360003391257945ab0585f"
10-
}
7+
"license": "MIT"
118
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# ws: a node.js websocket library #
2+
3+
This repository contains a minimal repackaging of ws for deployment.
4+
It is currently at version 0.4.25. The main repository for ws can be
5+
found at https://github.com/einaros/ws
6+
7+
This repository also incorporates options.js instead of relying on it
8+
as an external dependency. The main repository for options.js can be
9+
found at https://github.com/einaros/options.js
10+
11+
No modifications are made to either library except for a.) removing
12+
files that are not necessary for deployment and b.) fixing up paths
13+
14+
Both ws and options.js are written by Einar Otto Stangvik and licensed
15+
under the MIT license (see below).
16+
17+
## License for ws##
18+
19+
(The MIT License)
20+
21+
Copyright (c) 2011 Einar Otto Stangvik &lt;einaros@gmail.com&gt;
22+
23+
Permission is hereby granted, free of charge, to any person obtaining
24+
a copy of this software and associated documentation files (the
25+
'Software'), to deal in the Software without restriction, including
26+
without limitation the rights to use, copy, modify, merge, publish,
27+
distribute, sublicense, and/or sell copies of the Software, and to
28+
permit persons to whom the Software is furnished to do so, subject to
29+
the following conditions:
30+
31+
The above copyright notice and this permission notice shall be
32+
included in all copies or substantial portions of the Software.
33+
34+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
35+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
37+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
38+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
39+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
40+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41+
42+
## License for options.js##
43+
44+
(The MIT License)
45+
46+
Copyright (c) 2012 Einar Otto Stangvik &lt;einaros@gmail.com&gt;
47+
48+
Permission is hereby granted, free of charge, to any person obtaining
49+
a copy of this software and associated documentation files (the
50+
'Software'), to deal in the Software without restriction, including
51+
without limitation the rights to use, copy, modify, merge, publish,
52+
distribute, sublicense, and/or sell copies of the Software, and to
53+
permit persons to whom the Software is furnished to do so, subject to
54+
the following conditions:
55+
56+
The above copyright notice and this permission notice shall be
57+
included in all copies or substantial portions of the Software.
58+
59+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
60+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
61+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
62+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
63+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
64+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
65+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*!
2+
* ws: a node.js websocket client
3+
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
4+
* MIT Licensed
5+
*/
6+
7+
module.exports = require('./lib/WebSocket');
8+
module.exports.Server = require('./lib/WebSocketServer');
9+
module.exports.Sender = require('./lib/Sender');
10+
module.exports.Receiver = require('./lib/Receiver');
11+
12+
module.exports.createServer = function (options, connectionListener) {
13+
var server = new module.exports.Server(options);
14+
if (typeof connectionListener === 'function') {
15+
server.on('connection', connectionListener);
16+
}
17+
return server;
18+
};
19+
20+
module.exports.connect = module.exports.createConnection = function (address, openListener) {
21+
var client = new module.exports(address);
22+
if (typeof openListener === 'function') {
23+
client.on('open', openListener);
24+
}
25+
return client;
26+
};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*!
2+
* ws: a node.js websocket client
3+
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
4+
* MIT Licensed
5+
*/
6+
7+
var util = require('util');
8+
9+
function BufferPool(initialSize, growStrategy, shrinkStrategy) {
10+
if (typeof initialSize === 'function') {
11+
shrinkStrategy = growStrategy;
12+
growStrategy = initialSize;
13+
initialSize = 0;
14+
}
15+
else if (typeof initialSize === 'undefined') {
16+
initialSize = 0;
17+
}
18+
this._growStrategy = (growStrategy || function(db, size) {
19+
return db.used + size;
20+
}).bind(null, this);
21+
this._shrinkStrategy = (shrinkStrategy || function(db) {
22+
return initialSize;
23+
}).bind(null, this);
24+
this._buffer = initialSize ? new Buffer(initialSize) : null;
25+
this._offset = 0;
26+
this._used = 0;
27+
this._changeFactor = 0;
28+
this.__defineGetter__('size', function(){
29+
return this._buffer == null ? 0 : this._buffer.length;
30+
});
31+
this.__defineGetter__('used', function(){
32+
return this._used;
33+
});
34+
}
35+
36+
BufferPool.prototype.get = function(length) {
37+
if (this._buffer == null || this._offset + length > this._buffer.length) {
38+
var newBuf = new Buffer(this._growStrategy(length));
39+
this._buffer = newBuf;
40+
this._offset = 0;
41+
}
42+
this._used += length;
43+
var buf = this._buffer.slice(this._offset, this._offset + length);
44+
this._offset += length;
45+
return buf;
46+
}
47+
48+
BufferPool.prototype.reset = function(forceNewBuffer) {
49+
var len = this._shrinkStrategy();
50+
if (len < this.size) this._changeFactor -= 1;
51+
if (forceNewBuffer || this._changeFactor < -2) {
52+
this._changeFactor = 0;
53+
this._buffer = len ? new Buffer(len) : null;
54+
}
55+
this._offset = 0;
56+
this._used = 0;
57+
}
58+
59+
module.exports = BufferPool;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*!
2+
* ws: a node.js websocket client
3+
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
4+
* MIT Licensed
5+
*/
6+
7+
module.exports.BufferUtil = {
8+
merge: function(mergedBuffer, buffers) {
9+
var offset = 0;
10+
for (var i = 0, l = buffers.length; i < l; ++i) {
11+
var buf = buffers[i];
12+
buf.copy(mergedBuffer, offset);
13+
offset += buf.length;
14+
}
15+
},
16+
mask: function(source, mask, output, offset, length) {
17+
var maskNum = mask.readUInt32LE(0, true);
18+
var i = 0;
19+
for (; i < length - 3; i += 4) {
20+
var num = maskNum ^ source.readUInt32LE(i, true);
21+
if (num < 0) num = 4294967296 + num;
22+
output.writeUInt32LE(num, offset + i, true);
23+
}
24+
switch (length % 4) {
25+
case 3: output[offset + i + 2] = source[i + 2] ^ mask[2];
26+
case 2: output[offset + i + 1] = source[i + 1] ^ mask[1];
27+
case 1: output[offset + i] = source[i] ^ mask[0];
28+
case 0:;
29+
}
30+
},
31+
unmask: function(data, mask) {
32+
var maskNum = mask.readUInt32LE(0, true);
33+
var length = data.length;
34+
var i = 0;
35+
for (; i < length - 3; i += 4) {
36+
var num = maskNum ^ data.readUInt32LE(i, true);
37+
if (num < 0) num = 4294967296 + num;
38+
data.writeUInt32LE(num, i, true);
39+
}
40+
switch (length % 4) {
41+
case 3: data[i + 2] = data[i + 2] ^ mask[2];
42+
case 2: data[i + 1] = data[i + 1] ^ mask[1];
43+
case 1: data[i] = data[i] ^ mask[0];
44+
case 0:;
45+
}
46+
}
47+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*!
2+
* ws: a node.js websocket client
3+
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
4+
* MIT Licensed
5+
*/
6+
7+
module.exports = {
8+
isValidErrorCode: function(code) {
9+
return (code >= 1000 && code <= 1011 && code != 1004 && code != 1005 && code != 1006) ||
10+
(code >= 3000 && code <= 4999);
11+
},
12+
1000: 'normal',
13+
1001: 'going away',
14+
1002: 'protocol error',
15+
1003: 'unsupported data',
16+
1004: 'reserved',
17+
1005: 'reserved for extensions',
18+
1006: 'reserved for extensions',
19+
1007: 'inconsistent or invalid data',
20+
1008: 'policy violation',
21+
1009: 'message too big',
22+
1010: 'extension handshake missing',
23+
1011: 'an unexpected condition prevented the request from being fulfilled',
24+
};

0 commit comments

Comments
 (0)