chat4app-client-angular 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/chat4app-client-angular.umd.js +26 -25
- package/bundles/chat4app-client-angular.umd.js.map +1 -1
- package/bundles/chat4app-client-angular.umd.min.js +1 -1
- package/bundles/chat4app-client-angular.umd.min.js.map +1 -1
- package/chat4app-client-angular.metadata.json +1 -1
- package/esm2015/lib/chat4app-client-angular.service.js +26 -26
- package/fesm2015/chat4app-client-angular.js +25 -25
- package/fesm2015/chat4app-client-angular.js.map +1 -1
- package/lib/chat4app-client-angular.service.d.ts +1 -0
- package/lib/chat4app-client-angular.service.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1792,7 +1792,6 @@
|
|
|
1792
1792
|
var _this = this;
|
|
1793
1793
|
return new rxjs.Observable(function (subscriber) {
|
|
1794
1794
|
try {
|
|
1795
|
-
// 1. Validações Iniciais
|
|
1796
1795
|
if (!_this.chatServer || _this.chatServer.trim().length === 0) {
|
|
1797
1796
|
subscriber.error(new Error("Endpoint is empty"));
|
|
1798
1797
|
return;
|
|
@@ -1801,14 +1800,12 @@
|
|
|
1801
1800
|
subscriber.error(new Error("SecurityChatToken is empty"));
|
|
1802
1801
|
return;
|
|
1803
1802
|
}
|
|
1804
|
-
// 2. Lógica de Negócio
|
|
1805
1803
|
_this.setTokenChat4app(securityChatToken);
|
|
1806
1804
|
if (chatCallback && connectionClientId) {
|
|
1807
1805
|
_this.chatUserExternalId = connectionClientId;
|
|
1808
1806
|
_this.chatCallback = chatCallback;
|
|
1809
1807
|
_this.connectWebsocket();
|
|
1810
1808
|
}
|
|
1811
|
-
// 3. Emite o token e finaliza o fluxo
|
|
1812
1809
|
subscriber.next(securityChatToken);
|
|
1813
1810
|
subscriber.complete();
|
|
1814
1811
|
}
|
|
@@ -2123,33 +2120,13 @@
|
|
|
2123
2120
|
.then(function (nc) {
|
|
2124
2121
|
that.nc = nc;
|
|
2125
2122
|
var subject = "chat4app.config." + _this.configId + ".user." + _this.chatUserExternalId;
|
|
2126
|
-
|
|
2123
|
+
that.nc.subscribe(subject, function (msg) {
|
|
2127
2124
|
if (_this.debug) {
|
|
2128
2125
|
console.log(msg);
|
|
2129
2126
|
}
|
|
2130
2127
|
_this.processAndCallback(JSON.parse(msg.data));
|
|
2131
2128
|
});
|
|
2132
|
-
|
|
2133
|
-
try {
|
|
2134
|
-
clearInterval(_this.interval);
|
|
2135
|
-
}
|
|
2136
|
-
catch (e) {
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
that.interval = setInterval(function () {
|
|
2140
|
-
if (that.debug) {
|
|
2141
|
-
console.log("publish chat4app.user.online " + _this.chatUserExternalId + " ");
|
|
2142
|
-
}
|
|
2143
|
-
try {
|
|
2144
|
-
that.nc.publish("chat4app.user.online", _this.chatUserExternalId);
|
|
2145
|
-
}
|
|
2146
|
-
catch (e) {
|
|
2147
|
-
if (_this.debug) {
|
|
2148
|
-
console.log("try reconnect...");
|
|
2149
|
-
}
|
|
2150
|
-
_this.ensureConn();
|
|
2151
|
-
}
|
|
2152
|
-
}, 1000);
|
|
2129
|
+
_this.setIntervalPing();
|
|
2153
2130
|
if (_this.debug) {
|
|
2154
2131
|
console.log("Subscribe online chat4app.user." + _this.chatUserExternalId + ".online");
|
|
2155
2132
|
}
|
|
@@ -2159,6 +2136,30 @@
|
|
|
2159
2136
|
console.error("NATS Error:", err);
|
|
2160
2137
|
});
|
|
2161
2138
|
};
|
|
2139
|
+
Chat4appClientAngularService.prototype.setIntervalPing = function () {
|
|
2140
|
+
var _this = this;
|
|
2141
|
+
if (this.interval) {
|
|
2142
|
+
try {
|
|
2143
|
+
clearInterval(this.interval);
|
|
2144
|
+
}
|
|
2145
|
+
catch (e) {
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
this.interval = setInterval(function () {
|
|
2149
|
+
if (_this.debug) {
|
|
2150
|
+
console.log("publish chat4app.user.online " + _this.chatUserExternalId + " ");
|
|
2151
|
+
}
|
|
2152
|
+
try {
|
|
2153
|
+
_this.nc.publish("chat4app.user.online", _this.chatUserExternalId);
|
|
2154
|
+
}
|
|
2155
|
+
catch (e) {
|
|
2156
|
+
if (_this.debug) {
|
|
2157
|
+
console.log("try reconnect...");
|
|
2158
|
+
}
|
|
2159
|
+
_this.ensureConn();
|
|
2160
|
+
}
|
|
2161
|
+
}, 1000);
|
|
2162
|
+
};
|
|
2162
2163
|
Chat4appClientAngularService.prototype.disconnect = function () {
|
|
2163
2164
|
return this.disconnectInternal(false);
|
|
2164
2165
|
};
|