Browse Source

fixed crash issue with closed sockets

master
mort 8 years ago
parent
commit
837c13f35a
3 changed files with 9 additions and 2 deletions
  1. 1
    1
      examples/index.html
  2. 7
    0
      index.js
  3. 1
    1
      package.json

+ 1
- 1
examples/index.html View File

@@ -26,7 +26,7 @@
"or typing <code>send</code> in the server's console.";

//Listen to 'myEvent', which the server emits when you
//type 'say' in its console
//type 'send' in its console
sock.on("myEvent", function(data) {
console.log("Received myEvent from server!");
console.log(data);

+ 7
- 0
index.js View File

@@ -40,11 +40,18 @@ var util = require("util");
//Socket {
function Socket(websock) {
this._websock = websock;
this._ready = false;

websock.on("close", function() {
this._ready = false;
this.emit("close");
}.bind(this));

websock.on("ready", function() {
this._ready = true;
this.emit("ready");
});

websock.on("message", function(msg) {
var obj;
try {

+ 1
- 1
package.json View File

@@ -1,6 +1,6 @@
{
"name": "socksugar",
"version": "0.3.0",
"version": "0.3.1",
"description": "Websockets with sugar on top.",
"main": "index.js",
"scripts": {

Loading…
Cancel
Save