mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 13:03:20 +00:00
Replace hasSession by isConnected
This commit is contained in:
@@ -55,7 +55,7 @@ define([
|
|||||||
throw "You must define a websocket url";
|
throw "You must define a websocket url";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false === WSConnection.hasSession()) {
|
if (false === WSConnection.isConnected()) {
|
||||||
WSConnection.connect(options.wsurl);
|
WSConnection.connect(options.wsurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@ define([
|
|||||||
|
|
||||||
return _.extend({
|
return _.extend({
|
||||||
connect: function(url) {
|
connect: function(url) {
|
||||||
if (this.hasSession()) {
|
if (this.isConnected()) {
|
||||||
throw "Connection is already active";
|
throw "Connection is already active";
|
||||||
}
|
}
|
||||||
var that = this;
|
var that = this;
|
||||||
@@ -21,18 +21,18 @@ define([
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
close: function() {
|
close: function() {
|
||||||
if (false === this.hasSession()) {
|
if (false === this.isConnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
activeSession.close();
|
activeSession.close();
|
||||||
activeSession = null;
|
activeSession = null;
|
||||||
this.trigger("ws:session-close");
|
this.trigger("ws:session-close");
|
||||||
},
|
},
|
||||||
hasSession: function() {
|
isConnected: function() {
|
||||||
return activeSession !== null;
|
return activeSession !== null;
|
||||||
},
|
},
|
||||||
subscribe: function(topic, callback) {
|
subscribe: function(topic, callback) {
|
||||||
if (false === this.hasSession()) {
|
if (false === this.isConnected()) {
|
||||||
this.on("ws:connect", function(session) {
|
this.on("ws:connect", function(session) {
|
||||||
session.subscribe(topic, callback);
|
session.subscribe(topic, callback);
|
||||||
this.trigger("ws:session-subscribe", topic);
|
this.trigger("ws:session-subscribe", topic);
|
||||||
@@ -43,7 +43,7 @@ define([
|
|||||||
this.trigger("ws:session-subscribe", topic);
|
this.trigger("ws:session-subscribe", topic);
|
||||||
},
|
},
|
||||||
unsubscribe: function(topic, callback) {
|
unsubscribe: function(topic, callback) {
|
||||||
if (false === this.hasSession()) {
|
if (false === this.isConnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
activeSession.unsubscribe(topic, callback);
|
activeSession.unsubscribe(topic, callback);
|
||||||
|
Reference in New Issue
Block a user