Permalink
Browse files

Accommodate try{} to only capture JSON decoding errors, and show the …

…rest.

Version bump
  • Loading branch information...
1 parent 2358f44 commit 4cb4e265704206fcf415e637c57c6914dd10e372 @rauchg rauchg committed Apr 1, 2010
Showing with 23 additions and 23 deletions.
  1. +1 −1 lib/io.js
  2. +10 −10 lib/transport.js
  3. +12 −12 socket.io.js
View
@@ -7,7 +7,7 @@
*/
this.io = {
- version: '0.1.2',
+ version: '0.1.3',
setPath: function(path){
this.path = /\/$/.test(path) ? path : path + '/';
View
@@ -35,23 +35,23 @@
_onData: function(data){
try {
var msgs = json.decode(data);
- if (msgs.messages){
- for (var i = 0, l = msgs.messages.length; i < l; i++){
- this._onMessage(msgs.messages[i]);
- }
- }
} catch(e){}
+ if (msgs && msgs.messages){
+ for (var i = 0, l = msgs.messages.length; i < l; i++){
+ this._onMessage(msgs.messages[i]);
+ }
+ }
},
_onMessage: function(message){
if (!('sessionid' in this)){
try {
var obj = json.decode(message);
- if (obj.sessionid){
- this.sessionid = obj.sessionid;
- this._onConnect();
- }
- } catch(e){}
+ } catch(e){}
+ if (obj && obj.sessionid){
+ this.sessionid = obj.sessionid;
+ this._onConnect();
+ }
} else {
this.base._onMessage(message);
}
View
@@ -1,4 +1,4 @@
-/** Socket.IO 0.1.2 - Built with build.js */
+/** Socket.IO 0.1.3 - Built with build.js */
/**
* Socket.IO client
*
@@ -8,7 +8,7 @@
*/
this.io = {
- version: '0.1.2',
+ version: '0.1.3',
setPath: function(path){
this.path = /\/$/.test(path) ? path : path + '/';
@@ -402,23 +402,23 @@ io.util.Events = (function(){
_onData: function(data){
try {
var msgs = json.decode(data);
- if (msgs.messages){
- for (var i = 0, l = msgs.messages.length; i < l; i++){
- this._onMessage(msgs.messages[i]);
- }
- }
} catch(e){}
+ if (msgs && msgs.messages){
+ for (var i = 0, l = msgs.messages.length; i < l; i++){
+ this._onMessage(msgs.messages[i]);
+ }
+ }
},
_onMessage: function(message){
if (!('sessionid' in this)){
try {
var obj = json.decode(message);
- if (obj.sessionid){
- this.sessionid = obj.sessionid;
- this._onConnect();
- }
- } catch(e){}
+ } catch(e){}
+ if (obj && obj.sessionid){
+ this.sessionid = obj.sessionid;
+ this._onConnect();
+ }
} else {
this.base._onMessage(message);
}

0 comments on commit 4cb4e26

Please sign in to comment.