Comparing version 0.0.1 to 0.0.2
@@ -6,3 +6,3 @@ { | ||
"author": "Brian McKelvey <brian@worlize.com>", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"repository": { | ||
@@ -9,0 +9,0 @@ "type": "git", |
@@ -6,2 +6,4 @@ WebSocket Client & Server Implementation for Node | ||
**Note about FireFox 6: Firefox 6 re-enables support for WebSockets by default. It uses a prefixed constructor name, MozWebSocket(), to avoid conflicting with already deployed scripts. It also implements draft-07, so if you want to target Firefox 6, you will need to checkout my draft-07 branch, not the latest one.** | ||
Overview | ||
@@ -21,2 +23,15 @@ -------- | ||
Installation | ||
------------ | ||
In your project root: | ||
$ npm install websocket | ||
Then in your code: | ||
var WebSocketServer = require('websocket').server; | ||
var WebSocketClient = require('websocket').client; | ||
var WebSocketFrame = require('websocket').frame; | ||
var WebSocketRouter = require('websocket').router; | ||
Current Features: | ||
@@ -55,3 +70,3 @@ ----------------- | ||
#!/usr/bin/env node | ||
var WebSocketServer = require('../lib/WebSocketServer'); | ||
var WebSocketServer = require('websocket').server; | ||
var http = require('http'); | ||
@@ -96,3 +111,3 @@ | ||
#!/usr/bin/env node | ||
var WebSocketClient = require('../lib/WebSocketClient'); | ||
var WebSocketClient = require('websocket').client; | ||
@@ -99,0 +114,0 @@ var client = new WebSocketClient(); |
@@ -75,2 +75,4 @@ #!/usr/bin/env node | ||
var mirrorHistory = []; | ||
router.mount('*', 'lws-mirror-protocol', function(request) { | ||
@@ -81,6 +83,24 @@ // Should do origin verification here. You have to pass the accepted | ||
console.log((new Date()) + " lws-mirror-protocol connection accepted from " + connection.remoteAddress); | ||
console.log((new Date()) + " sending mirror protocol history to client " + connection.remoteAddress); | ||
if (mirrorHistory.length > 0) { | ||
connection.sendUTF(mirrorHistory.join('')); | ||
} | ||
mirrorConnections.push(connection); | ||
connection.on('message', function(message) { | ||
// We only care about text messages | ||
if (message.type === 'utf8') { | ||
// Clear canvas command received | ||
if (message.utf8Data === 'clear;') { | ||
mirrorHistory = []; | ||
} | ||
else { | ||
// Record all other commands in the history | ||
mirrorHistory.push(message.utf8Data); | ||
} | ||
// Re-broadcast the command to all connected clients | ||
mirrorConnections.forEach(function (outputConnection) { | ||
@@ -91,2 +111,4 @@ outputConnection.sendUTF(message.utf8Data); | ||
}); | ||
connection.on('close', function(connection) { | ||
@@ -129,2 +151,2 @@ var index = mirrorConnections.indexOf(connection); | ||
console.log("libwebsockets-test-server protocols."); | ||
console.log("Point your draft-07 complant browser to http://localhost:" + args.port + "/"); | ||
console.log("Point your draft-09 complant browser to http://localhost:" + args.port + "/"); |
@@ -620,5 +620,5 @@ /* | ||
wuint32(value[0], endian, buffer, offset); | ||
wuint32(value[1], endian, buffer, offset+3); | ||
wuint32(value[1], endian, buffer, offset+4); | ||
} else { | ||
wuint32(value[0], endian, buffer, offset+3); | ||
wuint32(value[0], endian, buffer, offset+4); | ||
wuint32(value[1], endian, buffer, offset); | ||
@@ -625,0 +625,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
242678
6403
149