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

"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);

+ 7
- 0
index.js View File

//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 {

+ 1
- 1
package.json View File

{ {
"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": {

Loading…
Cancel
Save