Replace hasSession by isConnected

This commit is contained in:
Nicolas Le Goff
2014-02-28 00:59:15 +01:00
parent af526beb41
commit 1e2cc2692e
2 changed files with 6 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ define([
return _.extend({
connect: function(url) {
if (this.hasSession()) {
if (this.isConnected()) {
throw "Connection is already active";
}
var that = this;
@@ -21,18 +21,18 @@ define([
});
},
close: function() {
if (false === this.hasSession()) {
if (false === this.isConnected()) {
return;
}
activeSession.close();
activeSession = null;
this.trigger("ws:session-close");
},
hasSession: function() {
isConnected: function() {
return activeSession !== null;
},
subscribe: function(topic, callback) {
if (false === this.hasSession()) {
if (false === this.isConnected()) {
this.on("ws:connect", function(session) {
session.subscribe(topic, callback);
this.trigger("ws:session-subscribe", topic);
@@ -43,7 +43,7 @@ define([
this.trigger("ws:session-subscribe", topic);
},
unsubscribe: function(topic, callback) {
if (false === this.hasSession()) {
if (false === this.isConnected()) {
return;
}
activeSession.unsubscribe(topic, callback);