| "or typing <code>send</code> in the server's console."; | "or typing <code>send</code> in the server's console."; | ||||
| //Listen to 'myEvent', which the server emits when you | //Listen to 'myEvent', which the server emits when you | ||||
| //type 'say' in its console | |||||
| //type 'send' in its console | |||||
| sock.on("myEvent", function(data) { | sock.on("myEvent", function(data) { | ||||
| console.log("Received myEvent from server!"); | console.log("Received myEvent from server!"); | ||||
| console.log(data); | console.log(data); |
| //Socket { | //Socket { | ||||
| function Socket(websock) { | function Socket(websock) { | ||||
| this._websock = websock; | this._websock = websock; | ||||
| this._ready = false; | |||||
| websock.on("close", function() { | websock.on("close", function() { | ||||
| this._ready = false; | |||||
| this.emit("close"); | this.emit("close"); | ||||
| }.bind(this)); | }.bind(this)); | ||||
| websock.on("ready", function() { | |||||
| this._ready = true; | |||||
| this.emit("ready"); | |||||
| }); | |||||
| websock.on("message", function(msg) { | websock.on("message", function(msg) { | ||||
| var obj; | var obj; | ||||
| try { | try { |
| { | { | ||||
| "name": "socksugar", | "name": "socksugar", | ||||
| "version": "0.3.0", | |||||
| "version": "0.3.1", | |||||
| "description": "Websockets with sugar on top.", | "description": "Websockets with sugar on top.", | ||||
| "main": "index.js", | "main": "index.js", | ||||
| "scripts": { | "scripts": { |