Add onConnect/onDisconnect callbacks

This commit is contained in:
Ian Gulliver
2014-05-27 15:48:03 -07:00
parent 1dd1490518
commit 6d6950624f
2 changed files with 31 additions and 6 deletions

View File

@@ -62,7 +62,9 @@ var typeLogin;
profile: string}} */
var typeLogout;
/** @typedef {{onLogin: (function(string, string)|undefined),
/** @typedef {{onConnect: (function()|undefined),
onDisconnect: (function()|undefined),
onLogin: (function(string, string)|undefined),
onLogout: (function(string)|undefined),
onMessage: (function(typeMessage)|undefined),
onPin: (function(typeMessage)|undefined),
@@ -847,6 +849,9 @@ Cosmopolite.prototype.onSocketOpen_ = function() {
if (this.channelState_ == this.ChannelState.OPENING) {
this.channelState_ = this.ChannelState.OPEN;
if (this.callbacks_.onConnect) {
this.callbacks_.onConnect();
}
} else {
return;
}
@@ -869,6 +874,9 @@ Cosmopolite.prototype.onSocketClose_ = function() {
if (this.channelState_ == this.ChannelState.OPEN) {
this.channelState_ = this.ChannelState.CLOSED;
if (this.callbacks_.onDisconnect) {
this.callbacks_.onDisconnect();
}
} else {
return;
}