chat4app-client-angular 1.0.15 → 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 +132 -331
- package/bundles/chat4app-client-angular.umd.js.map +1 -1
- package/bundles/chat4app-client-angular.umd.min.js +2 -2
- 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 +123 -274
- package/fesm2015/chat4app-client-angular.js +120 -271
- package/fesm2015/chat4app-client-angular.js.map +1 -1
- package/lib/chat4app-client-angular.service.d.ts +9 -7
- package/lib/chat4app-client-angular.service.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('chat4app-client-angular', ['exports', '@angular/core', '@angular/common/http'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["chat4app-client-angular"] = {}, global.ng.core, global.ng.common.http));
|
|
5
|
-
})(this, (function (exports, i0, i1) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('rxjs')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('chat4app-client-angular', ['exports', '@angular/core', '@angular/common/http', 'rxjs'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["chat4app-client-angular"] = {}, global.ng.core, global.ng.common.http, global.rxjs));
|
|
5
|
+
})(this, (function (exports, i0, i1, rxjs) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespace(e) {
|
|
8
8
|
if (e && e.__esModule) return e;
|
|
@@ -1778,6 +1778,7 @@
|
|
|
1778
1778
|
this.chatUrl = "";
|
|
1779
1779
|
this.debug = false;
|
|
1780
1780
|
this.chatUserExternalId = "";
|
|
1781
|
+
this.configId = "";
|
|
1781
1782
|
this.timeoutReconnect = 500;
|
|
1782
1783
|
}
|
|
1783
1784
|
Chat4appClientAngularService.prototype.ngOnInit = function () {
|
|
@@ -1787,28 +1788,31 @@
|
|
|
1787
1788
|
this.chatUrl = chat4AppConfig.endpoint + "/api/v1/";
|
|
1788
1789
|
this.debug = chat4AppConfig.debug;
|
|
1789
1790
|
};
|
|
1790
|
-
Chat4appClientAngularService.prototype.init = function (securityChatToken,
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
}
|
|
1798
|
-
if (!securityChatToken || securityChatToken.trim().length == 0) {
|
|
1799
|
-
throw new Error("SecurityChatToken is empty");
|
|
1800
|
-
}
|
|
1801
|
-
this.setTokenChat4app(securityChatToken);
|
|
1802
|
-
if (!(chatCallback && connectionClientId)) return [3 /*break*/, 2];
|
|
1803
|
-
return [4 /*yield*/, this.connectWebsocket(chatCallback, connectionClientId)];
|
|
1804
|
-
case 1:
|
|
1805
|
-
_b.sent();
|
|
1806
|
-
_b.label = 2;
|
|
1807
|
-
case 2:
|
|
1808
|
-
callback(securityChatToken);
|
|
1809
|
-
return [2 /*return*/];
|
|
1791
|
+
Chat4appClientAngularService.prototype.init = function (securityChatToken, chatCallback, connectionClientId) {
|
|
1792
|
+
var _this = this;
|
|
1793
|
+
return new rxjs.Observable(function (subscriber) {
|
|
1794
|
+
try {
|
|
1795
|
+
if (!_this.chatServer || _this.chatServer.trim().length === 0) {
|
|
1796
|
+
subscriber.error(new Error("Endpoint is empty"));
|
|
1797
|
+
return;
|
|
1810
1798
|
}
|
|
1811
|
-
|
|
1799
|
+
if (!securityChatToken || securityChatToken.trim().length === 0) {
|
|
1800
|
+
subscriber.error(new Error("SecurityChatToken is empty"));
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
_this.setTokenChat4app(securityChatToken);
|
|
1804
|
+
if (chatCallback && connectionClientId) {
|
|
1805
|
+
_this.chatUserExternalId = connectionClientId;
|
|
1806
|
+
_this.chatCallback = chatCallback;
|
|
1807
|
+
_this.connectWebsocket();
|
|
1808
|
+
}
|
|
1809
|
+
subscriber.next(securityChatToken);
|
|
1810
|
+
subscriber.complete();
|
|
1811
|
+
}
|
|
1812
|
+
catch (err) {
|
|
1813
|
+
// Captura erros inesperados e envia para o canal de erro do Observable
|
|
1814
|
+
subscriber.error(err);
|
|
1815
|
+
}
|
|
1812
1816
|
});
|
|
1813
1817
|
};
|
|
1814
1818
|
Chat4appClientAngularService.prototype.getChatUrlDownload = function (messageFileId) {
|
|
@@ -2098,250 +2102,103 @@
|
|
|
2098
2102
|
Chat4appClientAngularService.prototype.setTokenChat4app = function (chat4AppSessionToken) {
|
|
2099
2103
|
window.sessionStorage.setItem("chat4AppSessionToken", chat4AppSessionToken);
|
|
2100
2104
|
};
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
2108
|
-
chat4appMessage.data.externalId = data.externalId;
|
|
2109
|
-
chat4appMessage.data.fromId = data.fromId;
|
|
2110
|
-
chat4appMessage.data.toId = data.toId;
|
|
2111
|
-
chat4appMessage.data.groupId = data.groupId;
|
|
2112
|
-
chat4appMessage.data.dateHour = data.dateHour;
|
|
2113
|
-
chat4appMessage.data.type = data.type;
|
|
2114
|
-
chat4appMessage.notification.body = data.body;
|
|
2115
|
-
if (data.fileId && data.fileId.length > 0) {
|
|
2116
|
-
chat4appMessage.data.fileId = data.fileId;
|
|
2117
|
-
chat4appMessage.data.fileName = data.fileName;
|
|
2118
|
-
chat4appMessage.data.fileSize = data.fileSize;
|
|
2119
|
-
chat4appMessage.data.fileType = data.fileType;
|
|
2120
|
-
}
|
|
2121
|
-
var datTmp = new Map();
|
|
2122
|
-
for (var key in data) {
|
|
2123
|
-
datTmp.set(key, data[key]);
|
|
2124
|
-
}
|
|
2125
|
-
chat4appMessage.data.all = datTmp;
|
|
2126
|
-
chatCallback.onMessage(chat4appMessage);
|
|
2105
|
+
Chat4appClientAngularService.prototype.ensureConn = function () {
|
|
2106
|
+
var _this = this;
|
|
2107
|
+
if (this.debug) {
|
|
2108
|
+
console.log("chatServer: " + this.chatServer);
|
|
2109
|
+
console.log("userId: " + this.chatUserExternalId);
|
|
2110
|
+
console.log("getBearerToken: " + this.getBearerToken());
|
|
2127
2111
|
}
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
chat4appMessage.data.fromId = data.fromId;
|
|
2134
|
-
chat4appMessage.data.toId = data.toId;
|
|
2135
|
-
chat4appMessage.data.groupId = data.groupId;
|
|
2136
|
-
chat4appMessage.data.dateHour = data.dateHour;
|
|
2137
|
-
chat4appMessage.data.type = data.type;
|
|
2138
|
-
var datTmp = new Map();
|
|
2139
|
-
for (var key in data) {
|
|
2140
|
-
datTmp.set(key, data[key]);
|
|
2141
|
-
}
|
|
2142
|
-
chat4appMessage.data.all = datTmp;
|
|
2143
|
-
chatCallback.onOffline(chat4appMessage);
|
|
2144
|
-
}
|
|
2145
|
-
else if (data.type == "read") {
|
|
2146
|
-
var chat4appMessage = new Chat4AppMessageReceive();
|
|
2147
|
-
chat4appMessage.data.chatId = data.chatId;
|
|
2148
|
-
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
2149
|
-
chat4appMessage.data.externalId = data.externalId;
|
|
2150
|
-
chat4appMessage.data.fromId = data.fromId;
|
|
2151
|
-
chat4appMessage.data.toId = data.toId;
|
|
2152
|
-
chat4appMessage.data.groupId = data.groupId;
|
|
2153
|
-
chat4appMessage.data.dateHour = data.dateHour;
|
|
2154
|
-
chat4appMessage.data.type = data.type;
|
|
2155
|
-
var datTmp = new Map();
|
|
2156
|
-
for (var key in data) {
|
|
2157
|
-
datTmp.set(key, data[key]);
|
|
2158
|
-
}
|
|
2159
|
-
chat4appMessage.data.all = datTmp;
|
|
2160
|
-
chatCallback.onRead(chat4appMessage);
|
|
2112
|
+
var that = this;
|
|
2113
|
+
var uriStep1 = this.chatServer.replace(/^https/, 'wss');
|
|
2114
|
+
var server = uriStep1.replace(/(\/\/.*?)\//, '$1\/ws/');
|
|
2115
|
+
if (this.debug) {
|
|
2116
|
+
console.log("ws server: " + server);
|
|
2161
2117
|
}
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2118
|
+
that.disconnectInternal(true);
|
|
2119
|
+
nats_min.connect({ url: server, user: this.chatUserExternalId, pass: this.getBearerToken(), reconnect: false })
|
|
2120
|
+
.then(function (nc) {
|
|
2121
|
+
that.nc = nc;
|
|
2122
|
+
var subject = "chat4app.config." + _this.configId + ".user." + _this.chatUserExternalId;
|
|
2123
|
+
that.nc.subscribe(subject, function (msg) {
|
|
2124
|
+
if (_this.debug) {
|
|
2125
|
+
console.log(msg);
|
|
2126
|
+
}
|
|
2127
|
+
_this.processAndCallback(JSON.parse(msg.data));
|
|
2128
|
+
});
|
|
2129
|
+
_this.setIntervalPing();
|
|
2130
|
+
if (_this.debug) {
|
|
2131
|
+
console.log("Subscribe online chat4app.user." + _this.chatUserExternalId + ".online");
|
|
2175
2132
|
}
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
chat4appMessage.data.dateHour = data.dateHour;
|
|
2188
|
-
chat4appMessage.data.type = data.type;
|
|
2189
|
-
var datTmp = new Map();
|
|
2190
|
-
for (var key in data) {
|
|
2191
|
-
datTmp.set(key, data[key]);
|
|
2133
|
+
})
|
|
2134
|
+
.catch(function (err) {
|
|
2135
|
+
// Notifica o chamador sobre o erro na conexão
|
|
2136
|
+
console.error("NATS Error:", err);
|
|
2137
|
+
});
|
|
2138
|
+
};
|
|
2139
|
+
Chat4appClientAngularService.prototype.setIntervalPing = function () {
|
|
2140
|
+
var _this = this;
|
|
2141
|
+
if (this.interval) {
|
|
2142
|
+
try {
|
|
2143
|
+
clearInterval(this.interval);
|
|
2192
2144
|
}
|
|
2193
|
-
|
|
2194
|
-
chatCallback.onNewUser(chat4appMessage);
|
|
2195
|
-
}
|
|
2196
|
-
else if (data.type == "remove_user") {
|
|
2197
|
-
var chat4appMessage = new Chat4AppMessageReceive();
|
|
2198
|
-
chat4appMessage.data.chatId = data.chatId;
|
|
2199
|
-
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
2200
|
-
chat4appMessage.data.externalId = data.externalId;
|
|
2201
|
-
chat4appMessage.data.fromId = data.fromId;
|
|
2202
|
-
chat4appMessage.data.toId = data.toId;
|
|
2203
|
-
chat4appMessage.data.groupId = data.groupId;
|
|
2204
|
-
chat4appMessage.data.dateHour = data.dateHour;
|
|
2205
|
-
chat4appMessage.data.type = data.type;
|
|
2206
|
-
var datTmp = new Map();
|
|
2207
|
-
for (var key in data) {
|
|
2208
|
-
datTmp.set(key, data[key]);
|
|
2145
|
+
catch (e) {
|
|
2209
2146
|
}
|
|
2210
|
-
chat4appMessage.data.all = datTmp;
|
|
2211
|
-
chatCallback.onRemoveUser(chat4appMessage);
|
|
2212
2147
|
}
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
2217
|
-
chat4appMessage.data.externalId = data.externalId;
|
|
2218
|
-
chat4appMessage.data.fromId = data.fromId;
|
|
2219
|
-
chat4appMessage.data.toId = data.toId;
|
|
2220
|
-
chat4appMessage.data.groupId = data.groupId;
|
|
2221
|
-
chat4appMessage.data.dateHour = data.dateHour;
|
|
2222
|
-
chat4appMessage.data.type = data.type;
|
|
2223
|
-
var datTmp = new Map();
|
|
2224
|
-
for (var key in data) {
|
|
2225
|
-
datTmp.set(key, data[key]);
|
|
2148
|
+
this.interval = setInterval(function () {
|
|
2149
|
+
if (_this.debug) {
|
|
2150
|
+
console.log("publish chat4app.user.online " + _this.chatUserExternalId + " ");
|
|
2226
2151
|
}
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
}
|
|
2230
|
-
else if (data.type == "count_notread") {
|
|
2231
|
-
var chat4appMessage = new Chat4AppMessageReceive();
|
|
2232
|
-
chat4appMessage.data.chatId = data.chatId;
|
|
2233
|
-
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
2234
|
-
chat4appMessage.data.externalId = data.externalId;
|
|
2235
|
-
chat4appMessage.data.fromId = data.fromId;
|
|
2236
|
-
chat4appMessage.data.toId = data.toId;
|
|
2237
|
-
chat4appMessage.data.groupId = data.groupId;
|
|
2238
|
-
chat4appMessage.data.dateHour = data.dateHour;
|
|
2239
|
-
chat4appMessage.data.type = data.type;
|
|
2240
|
-
var datTmp = new Map();
|
|
2241
|
-
for (var key in data) {
|
|
2242
|
-
datTmp.set(key, data[key]);
|
|
2152
|
+
try {
|
|
2153
|
+
_this.nc.publish("chat4app.user.online", _this.chatUserExternalId);
|
|
2243
2154
|
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
};
|
|
2248
|
-
Chat4appClientAngularService.prototype.ensureConn = function (chatUserExternalId, forceReconnectNats) {
|
|
2249
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2250
|
-
var that, uriStep1, server, _b;
|
|
2251
|
-
return __generator(this, function (_c) {
|
|
2252
|
-
switch (_c.label) {
|
|
2253
|
-
case 0:
|
|
2254
|
-
if (this.debug) {
|
|
2255
|
-
console.log("chatServer: " + this.chatServer);
|
|
2256
|
-
console.log("userId: " + chatUserExternalId);
|
|
2257
|
-
console.log("getBearerToken: " + this.getBearerToken());
|
|
2258
|
-
}
|
|
2259
|
-
that = this;
|
|
2260
|
-
uriStep1 = this.chatServer.replace(/^https/, 'wss');
|
|
2261
|
-
server = uriStep1.replace(/(\/\/.*?)\//, '$1\/ws/');
|
|
2262
|
-
if (this.debug) {
|
|
2263
|
-
console.log("ws server: " + server);
|
|
2264
|
-
}
|
|
2265
|
-
if (!(forceReconnectNats || !this.nc || (this.nc.isClose && this.nc.isClose()))) return [3 /*break*/, 3];
|
|
2266
|
-
return [4 /*yield*/, that.disconnectInternal(true)];
|
|
2267
|
-
case 1:
|
|
2268
|
-
_c.sent();
|
|
2269
|
-
_b = that;
|
|
2270
|
-
return [4 /*yield*/, nats_min.connect({ url: server, user: chatUserExternalId, pass: this.getBearerToken(), reconnect: false })];
|
|
2271
|
-
case 2:
|
|
2272
|
-
_b.nc = _c.sent();
|
|
2273
|
-
_c.label = 3;
|
|
2274
|
-
case 3:
|
|
2275
|
-
this.chatUserExternalId = chatUserExternalId;
|
|
2276
|
-
return [2 /*return*/, that.nc];
|
|
2155
|
+
catch (e) {
|
|
2156
|
+
if (_this.debug) {
|
|
2157
|
+
console.log("try reconnect...");
|
|
2277
2158
|
}
|
|
2278
|
-
|
|
2279
|
-
|
|
2159
|
+
_this.ensureConn();
|
|
2160
|
+
}
|
|
2161
|
+
}, 1000);
|
|
2280
2162
|
};
|
|
2281
2163
|
Chat4appClientAngularService.prototype.disconnect = function () {
|
|
2282
|
-
return
|
|
2283
|
-
return __generator(this, function (_b) {
|
|
2284
|
-
return [2 /*return*/, this.disconnectInternal(false)];
|
|
2285
|
-
});
|
|
2286
|
-
});
|
|
2164
|
+
return this.disconnectInternal(false);
|
|
2287
2165
|
};
|
|
2288
2166
|
Chat4appClientAngularService.prototype.disconnectInternal = function (ignoreOffLine) {
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
console.error("Erro ao setar offline", e_1);
|
|
2316
|
-
return [3 /*break*/, 4];
|
|
2317
|
-
case 4:
|
|
2318
|
-
if (!this.nc) return [3 /*break*/, 9];
|
|
2319
|
-
_b.label = 5;
|
|
2320
|
-
case 5:
|
|
2321
|
-
_b.trys.push([5, 7, , 8]);
|
|
2322
|
-
return [4 /*yield*/, this.nc.close()];
|
|
2323
|
-
case 6:
|
|
2324
|
-
_b.sent();
|
|
2325
|
-
return [3 /*break*/, 8];
|
|
2326
|
-
case 7:
|
|
2327
|
-
e_2 = _b.sent();
|
|
2328
|
-
if (this.debug) {
|
|
2329
|
-
console.error(e_2);
|
|
2330
|
-
}
|
|
2331
|
-
return [3 /*break*/, 8];
|
|
2332
|
-
case 8:
|
|
2333
|
-
this.nc = undefined;
|
|
2334
|
-
_b.label = 9;
|
|
2335
|
-
case 9:
|
|
2336
|
-
if (this.debug) {
|
|
2337
|
-
console.log("disconect");
|
|
2338
|
-
}
|
|
2339
|
-
return [2 /*return*/];
|
|
2167
|
+
// Check how we can disconnect
|
|
2168
|
+
if (this.interval) {
|
|
2169
|
+
try {
|
|
2170
|
+
clearInterval(this.interval);
|
|
2171
|
+
}
|
|
2172
|
+
catch (e) {
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
if (!ignoreOffLine && this.nc && this.chatUserExternalId && this.chatUserExternalId.length > 0 && this.getBearerToken() && this.getBearerToken().length > 0) {
|
|
2176
|
+
try {
|
|
2177
|
+
this.setOffLine(this.chatUserExternalId).toPromise();
|
|
2178
|
+
if (this.debug)
|
|
2179
|
+
console.log("had set offline");
|
|
2180
|
+
}
|
|
2181
|
+
catch (e) {
|
|
2182
|
+
if (this.debug)
|
|
2183
|
+
console.error("Erro ao setar offline", e);
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
if (this.nc) {
|
|
2187
|
+
try {
|
|
2188
|
+
this.nc.close();
|
|
2189
|
+
}
|
|
2190
|
+
catch (e) {
|
|
2191
|
+
if (this.debug) {
|
|
2192
|
+
console.error(e);
|
|
2340
2193
|
}
|
|
2341
|
-
}
|
|
2342
|
-
|
|
2194
|
+
}
|
|
2195
|
+
this.nc = undefined;
|
|
2196
|
+
}
|
|
2197
|
+
if (this.debug) {
|
|
2198
|
+
console.log("disconect");
|
|
2199
|
+
}
|
|
2343
2200
|
};
|
|
2344
|
-
Chat4appClientAngularService.prototype.processAndCallback = function (msgObj
|
|
2201
|
+
Chat4appClientAngularService.prototype.processAndCallback = function (msgObj) {
|
|
2345
2202
|
if (this.debug && msgObj) {
|
|
2346
2203
|
console.log("Msg Received: " + JSON.stringify(msgObj));
|
|
2347
2204
|
}
|
|
@@ -2352,101 +2209,45 @@
|
|
|
2352
2209
|
}
|
|
2353
2210
|
msgObj.data.all = datTmp;
|
|
2354
2211
|
if (msgObj.data.type == "msg") {
|
|
2355
|
-
chatCallback.onMessage(msgObj);
|
|
2212
|
+
this.chatCallback.onMessage(msgObj);
|
|
2356
2213
|
}
|
|
2357
2214
|
else if ((msgObj.data.type == "on" || msgObj.data.type == "off")) {
|
|
2358
|
-
chatCallback.onOffline(msgObj);
|
|
2215
|
+
this.chatCallback.onOffline(msgObj);
|
|
2359
2216
|
}
|
|
2360
2217
|
else if (msgObj.data.type == "read") {
|
|
2361
|
-
chatCallback.onRead(msgObj);
|
|
2218
|
+
this.chatCallback.onRead(msgObj);
|
|
2362
2219
|
}
|
|
2363
2220
|
else if (msgObj.data.type == "startTyping" || msgObj.data.type == "stopTyping") {
|
|
2364
|
-
chatCallback.onStartStopTyping(msgObj);
|
|
2221
|
+
this.chatCallback.onStartStopTyping(msgObj);
|
|
2365
2222
|
}
|
|
2366
2223
|
else if (msgObj.data.type == "new_user") {
|
|
2367
|
-
chatCallback.onNewUser(msgObj);
|
|
2224
|
+
this.chatCallback.onNewUser(msgObj);
|
|
2368
2225
|
}
|
|
2369
2226
|
else if (msgObj.data.type == "remove_user") {
|
|
2370
|
-
chatCallback.onRemoveUser(msgObj);
|
|
2227
|
+
this.chatCallback.onRemoveUser(msgObj);
|
|
2371
2228
|
}
|
|
2372
2229
|
else if (msgObj.data.type == "chat_closed") {
|
|
2373
|
-
chatCallback.onChatClosed(msgObj);
|
|
2230
|
+
this.chatCallback.onChatClosed(msgObj);
|
|
2374
2231
|
}
|
|
2375
2232
|
else if (msgObj.data.type == "count_notread") {
|
|
2376
|
-
chatCallback.onCountNotRead(msgObj);
|
|
2233
|
+
this.chatCallback.onCountNotRead(msgObj);
|
|
2377
2234
|
}
|
|
2378
2235
|
//}
|
|
2379
2236
|
};
|
|
2380
|
-
Chat4appClientAngularService.prototype.connectWebsocket = function (
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
that = this;
|
|
2388
|
-
this.disconnectInternal(true);
|
|
2389
|
-
securityToken = this.getBearerToken();
|
|
2390
|
-
tokenAuth = "";
|
|
2391
|
-
if (securityToken && securityToken.startsWith("Bearer ")) {
|
|
2392
|
-
tokenAuth = securityToken;
|
|
2393
|
-
}
|
|
2394
|
-
else {
|
|
2395
|
-
tokenAuth = "Bearer " + securityToken;
|
|
2396
|
-
}
|
|
2397
|
-
configId = this.chatServer.split("/")[3];
|
|
2398
|
-
return [4 /*yield*/, this.ensureConn(userId)];
|
|
2399
|
-
case 1:
|
|
2400
|
-
nc = _b.sent();
|
|
2401
|
-
subject = "chat4app.config." + configId + ".user." + userId;
|
|
2402
|
-
sub = nc.subscribe(subject, function (msg) {
|
|
2403
|
-
if (_this.debug) {
|
|
2404
|
-
console.log(msg);
|
|
2405
|
-
}
|
|
2406
|
-
_this.processAndCallback(JSON.parse(msg.data), chatCallback);
|
|
2407
|
-
});
|
|
2408
|
-
if (this.interval) {
|
|
2409
|
-
try {
|
|
2410
|
-
clearInterval(this.interval);
|
|
2411
|
-
}
|
|
2412
|
-
catch (e) {
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
that.interval = setInterval(function () {
|
|
2416
|
-
if (that.debug) {
|
|
2417
|
-
console.log("publish chat4app.user.online " + userId + " ");
|
|
2418
|
-
}
|
|
2419
|
-
try {
|
|
2420
|
-
that.nc.publish("chat4app.user.online", userId);
|
|
2421
|
-
}
|
|
2422
|
-
catch (e) {
|
|
2423
|
-
if (_this.debug) {
|
|
2424
|
-
console.log("try reconnect...");
|
|
2425
|
-
}
|
|
2426
|
-
_this.ensureConn(userId, true);
|
|
2427
|
-
}
|
|
2428
|
-
}, 1000);
|
|
2429
|
-
if (this.debug) {
|
|
2430
|
-
console.log("Subscribe online chat4app.user." + userId + ".online");
|
|
2431
|
-
}
|
|
2432
|
-
return [2 /*return*/];
|
|
2433
|
-
}
|
|
2434
|
-
});
|
|
2435
|
-
});
|
|
2436
|
-
};
|
|
2437
|
-
/*
|
|
2438
|
-
disconnect() {
|
|
2439
|
-
// console.log("disconnect")
|
|
2440
|
-
try {
|
|
2441
|
-
if (this.stompClient) {
|
|
2442
|
-
this.stompClient.disconnect();
|
|
2237
|
+
Chat4appClientAngularService.prototype.connectWebsocket = function () {
|
|
2238
|
+
var that = this;
|
|
2239
|
+
this.disconnectInternal(true);
|
|
2240
|
+
var securityToken = this.getBearerToken();
|
|
2241
|
+
var tokenAuth = "";
|
|
2242
|
+
if (securityToken && securityToken.startsWith("Bearer ")) {
|
|
2243
|
+
tokenAuth = securityToken;
|
|
2443
2244
|
}
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2245
|
+
else {
|
|
2246
|
+
tokenAuth = "Bearer " + securityToken;
|
|
2247
|
+
}
|
|
2248
|
+
this.configId = this.chatServer.split("/")[3];
|
|
2249
|
+
this.ensureConn();
|
|
2250
|
+
};
|
|
2450
2251
|
Chat4appClientAngularService.prototype.convertChat4AppMessageReceiveToChatMessage4App = function (msg) {
|
|
2451
2252
|
var _a;
|
|
2452
2253
|
var message = new ChatMessage4App();
|