chat4app-client-angular 0.0.2 → 0.0.5
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 +406 -408
- 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.d.ts +4 -4
- package/chat4app-client-angular.metadata.json +1 -1
- package/esm2015/chat4app-client-angular.js +4 -4
- package/esm2015/lib/chat4app-client-angular.component.js +13 -13
- package/esm2015/lib/chat4app-client-angular.module.js +11 -11
- package/esm2015/lib/chat4app-client-angular.service.js +356 -357
- package/esm2015/public-api.js +6 -6
- package/fesm2015/chat4app-client-angular.js +370 -371
- package/fesm2015/chat4app-client-angular.js.map +1 -1
- package/lib/chat4app-client-angular.component.d.ts +5 -5
- package/lib/chat4app-client-angular.module.d.ts +2 -2
- package/lib/chat4app-client-angular.service.d.ts +134 -135
- package/lib/chat4app-client-angular.service.d.ts.map +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +3 -3
|
@@ -6,389 +6,388 @@ import * as i1 from '@angular/common/http';
|
|
|
6
6
|
import { HttpHeaders, HttpClient } from '@angular/common/http';
|
|
7
7
|
import * as moment from 'moment';
|
|
8
8
|
|
|
9
|
-
class Chat4appClientAngularService {
|
|
10
|
-
constructor(http) {
|
|
11
|
-
this.http = http;
|
|
12
|
-
this.chatServer = "";
|
|
13
|
-
this.chatUrl = "";
|
|
14
|
-
}
|
|
15
|
-
ngOnInit() {
|
|
16
|
-
}
|
|
17
|
-
config(chat4AppConfig) {
|
|
18
|
-
this.chatServer = chat4AppConfig.endpoint;
|
|
19
|
-
this.chatUrl = chat4AppConfig.endpoint + "/api/v1/";
|
|
20
|
-
}
|
|
21
|
-
init(callback, chatCallback,
|
|
22
|
-
if (!this.chatServer || this.chatServer.trim().length == 0) {
|
|
23
|
-
throw new Error("
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
formData
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
formData
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
chat4appMessage.data.
|
|
200
|
-
chat4appMessage.data.
|
|
201
|
-
chat4appMessage.data.
|
|
202
|
-
chat4appMessage.data.
|
|
203
|
-
chat4appMessage.data.
|
|
204
|
-
chat4appMessage.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
chat4appMessage.data.
|
|
209
|
-
chat4appMessage.data.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
chat4appMessage.data.
|
|
223
|
-
chat4appMessage.data.
|
|
224
|
-
chat4appMessage.data.
|
|
225
|
-
chat4appMessage.data.
|
|
226
|
-
chat4appMessage.data.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
this.
|
|
239
|
-
|
|
240
|
-
this.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
let
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
//
|
|
264
|
-
//
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
message.
|
|
291
|
-
message.
|
|
292
|
-
message.
|
|
293
|
-
message.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
messageFile.
|
|
298
|
-
messageFile.
|
|
299
|
-
messageFile.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
Chat4appClientAngularService
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
this.
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
ChatStatus4App["
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
ChatFilterType[ChatFilterType["
|
|
356
|
-
ChatFilterType[ChatFilterType["LAST_MESSAGE"] = 2] = "LAST_MESSAGE";
|
|
9
|
+
class Chat4appClientAngularService {
|
|
10
|
+
constructor(http) {
|
|
11
|
+
this.http = http;
|
|
12
|
+
this.chatServer = "";
|
|
13
|
+
this.chatUrl = "";
|
|
14
|
+
}
|
|
15
|
+
ngOnInit() {
|
|
16
|
+
}
|
|
17
|
+
config(chat4AppConfig) {
|
|
18
|
+
this.chatServer = chat4AppConfig.endpoint;
|
|
19
|
+
this.chatUrl = chat4AppConfig.endpoint + "/api/v1/";
|
|
20
|
+
}
|
|
21
|
+
init(securityChatToken, callback, chatCallback, connectionClientId) {
|
|
22
|
+
if (!this.chatServer || this.chatServer.trim().length == 0) {
|
|
23
|
+
throw new Error("Endpoint is empty");
|
|
24
|
+
}
|
|
25
|
+
if (!securityChatToken || securityChatToken.trim().length == 0) {
|
|
26
|
+
throw new Error("SecurityChatToken is empty");
|
|
27
|
+
}
|
|
28
|
+
this.setTokenChat4app(securityChatToken);
|
|
29
|
+
if (chatCallback && connectionClientId) {
|
|
30
|
+
this.connectWebsocket(chatCallback, connectionClientId);
|
|
31
|
+
}
|
|
32
|
+
callback(securityChatToken);
|
|
33
|
+
}
|
|
34
|
+
getChatUrlDownload(messageFileId) {
|
|
35
|
+
return this.chatUrl + "chatmessage/getFile?messageFileId=" + messageFileId;
|
|
36
|
+
}
|
|
37
|
+
getMessageChat(chatId, fromId, toId) {
|
|
38
|
+
let url = this.chatUrl + "chatmessage/" + chatId + "/" + fromId + "/" + toId;
|
|
39
|
+
return this.http.get(url, {
|
|
40
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getMessageChatByGrop(chatId, groupId, fromId) {
|
|
44
|
+
let url = this.chatUrl + "chatmessage/byGroup/" + chatId + "/" + groupId + "/" + fromId;
|
|
45
|
+
return this.http.get(url, {
|
|
46
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
addMessageChat(chatMessage4App) {
|
|
50
|
+
let url = this.chatUrl + "chatmessage/" + chatMessage4App.chatId;
|
|
51
|
+
return this.http.post(url, chatMessage4App, {
|
|
52
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
props(chatFilterRequest4App) {
|
|
56
|
+
let url = this.chatUrl + "chatmessage/props";
|
|
57
|
+
return this.http.post(url, chatFilterRequest4App, {
|
|
58
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
removeUsersChat(chatId, chatUsersId, chatUsersExternalId) {
|
|
62
|
+
let params = new Array();
|
|
63
|
+
if (chatUsersId && chatUsersId.length > 0) {
|
|
64
|
+
chatUsersId.forEach(cui => {
|
|
65
|
+
params.push("chatUserId=" + cui);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else if (chatUsersExternalId && chatUsersExternalId.length > 0) {
|
|
69
|
+
chatUsersExternalId.forEach(cuei => {
|
|
70
|
+
params.push("chatUserExternalId=" + cuei);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
let url = this.chatUrl + "chatuser/" + chatId + "?" + params.join("&");
|
|
74
|
+
return this.http.delete(url, {
|
|
75
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
removeUserChat(chatId, chatUserId, chatUserExternalId) {
|
|
79
|
+
let param = "";
|
|
80
|
+
if (chatUserId) {
|
|
81
|
+
param = "chatUserId=" + chatUserId;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
param = "chatUserExternalId=" + chatUserExternalId;
|
|
85
|
+
}
|
|
86
|
+
let url = this.chatUrl + "chatuser/" + chatId + "?" + param;
|
|
87
|
+
return this.http.delete(url, {
|
|
88
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
updateUserChat(chatId, charUser4AppUpdate) {
|
|
92
|
+
let url = this.chatUrl + "chatuser/" + chatId;
|
|
93
|
+
return this.http.put(url, charUser4AppUpdate, {
|
|
94
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
createUserChat(chatId, chatUser4App) {
|
|
98
|
+
let url = this.chatUrl + "chatuser/" + chatId;
|
|
99
|
+
return this.http.post(url, chatUser4App, {
|
|
100
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
createUsersChat(chatId, chatUser4App) {
|
|
104
|
+
let url = this.chatUrl + "chatuser/users/" + chatId;
|
|
105
|
+
return this.http.post(url, chatUser4App, {
|
|
106
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
createChat(chat4app) {
|
|
110
|
+
let url = this.chatUrl + "chat";
|
|
111
|
+
return this.http.post(url, chat4app, {
|
|
112
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
createUpdateChat(chat4app) {
|
|
116
|
+
let url = this.chatUrl + "chat";
|
|
117
|
+
return this.http.put(url, chat4app, {
|
|
118
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
getLastMessageGroup(chatExternalId, groupId) {
|
|
122
|
+
let url = this.chatUrl + "chatmessage/lastMessageGroup?chatExternalId=" + chatExternalId + "&groupId=" + groupId;
|
|
123
|
+
return this.http.get(url, {
|
|
124
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
getLastMessage(chatExternalId, chatUserExternalId) {
|
|
128
|
+
let url = this.chatUrl + "chatmessage/lastMessage?chatExternalId=" + chatExternalId + "&chatUserExternalId=" + chatUserExternalId;
|
|
129
|
+
return this.http.get(url, {
|
|
130
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
countNotReadMessages(chatUserExternalId, chatExternalId, groupId) {
|
|
134
|
+
let url = this.chatUrl + "chatmessage/countNotReadMessages?chatUserExternalId=" + chatUserExternalId;
|
|
135
|
+
if (chatExternalId && chatExternalId.length > 0) {
|
|
136
|
+
url += "&chatExternalId=" + chatExternalId;
|
|
137
|
+
}
|
|
138
|
+
if (groupId && groupId.length > 0) {
|
|
139
|
+
url += "&groupId=" + groupId;
|
|
140
|
+
}
|
|
141
|
+
return this.http.get(url, {
|
|
142
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
getChatByExternalId(externalId) {
|
|
146
|
+
let url = this.chatUrl + "chat?externalId=" + externalId;
|
|
147
|
+
return this.http.get(url, {
|
|
148
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
readMessage(chatMessageId, toId) {
|
|
152
|
+
let url = this.chatUrl + "chatmessage/read/" + chatMessageId;
|
|
153
|
+
if (toId && toId.length > 0) {
|
|
154
|
+
url += "/" + toId;
|
|
155
|
+
}
|
|
156
|
+
return this.http.put(url, null, {
|
|
157
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
online(chatId, chatUserId) {
|
|
161
|
+
let url = this.chatUrl + "chatmessage/online/" + chatId + "/" + chatUserId;
|
|
162
|
+
return this.http.get(url, {
|
|
163
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
sendFile(chatId, fromId, toId, fileToUpload) {
|
|
167
|
+
const endpoint = this.chatUrl + "chatmessage/sendFile/" + chatId + "/" + fromId + "/" + toId;
|
|
168
|
+
const formData = new FormData();
|
|
169
|
+
formData.append('file', fileToUpload);
|
|
170
|
+
return this.http
|
|
171
|
+
.post(endpoint, formData, {
|
|
172
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
sendFileGroup(chatId, fromId, groupId, fileToUpload) {
|
|
176
|
+
const endpoint = this.chatUrl + "chatmessage/sendFileGroup/" + chatId + "/" + fromId + "/" + groupId;
|
|
177
|
+
const formData = new FormData();
|
|
178
|
+
formData.append('file', fileToUpload);
|
|
179
|
+
return this.http
|
|
180
|
+
.post(endpoint, formData, {
|
|
181
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/* Token */
|
|
185
|
+
getBearerToken() {
|
|
186
|
+
let ret = "Bearer " + window.sessionStorage.getItem("chat4AppSessionToken");
|
|
187
|
+
return ret;
|
|
188
|
+
}
|
|
189
|
+
setTokenChat4app(chat4AppSessionToken) {
|
|
190
|
+
window.sessionStorage.setItem("chat4AppSessionToken", chat4AppSessionToken);
|
|
191
|
+
}
|
|
192
|
+
/* Connection */
|
|
193
|
+
onMessageFirebaseReceived(data, chatCallback) {
|
|
194
|
+
//alert("onMessageReceived connectFirebase");
|
|
195
|
+
if (data.type == "msg") {
|
|
196
|
+
let chat4appMessage = new Chat4AppMessageReceive();
|
|
197
|
+
chat4appMessage.data.chatId = data.chatId;
|
|
198
|
+
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
199
|
+
chat4appMessage.data.externalId = data.externalId;
|
|
200
|
+
chat4appMessage.data.fromId = data.fromId;
|
|
201
|
+
chat4appMessage.data.toId = data.toId;
|
|
202
|
+
chat4appMessage.data.dateHour = data.dateHour;
|
|
203
|
+
chat4appMessage.data.type = data.type;
|
|
204
|
+
chat4appMessage.notification.body = data.body;
|
|
205
|
+
if (data.fileId && data.fileId.length > 0) {
|
|
206
|
+
chat4appMessage.data.fileId = data.fileId;
|
|
207
|
+
chat4appMessage.data.fileName = data.fileName;
|
|
208
|
+
chat4appMessage.data.fileSize = data.fileSize;
|
|
209
|
+
chat4appMessage.data.fileType = data.fileType;
|
|
210
|
+
}
|
|
211
|
+
let datTmp = new Map();
|
|
212
|
+
for (let key in data) {
|
|
213
|
+
datTmp.set(key, data[key]);
|
|
214
|
+
}
|
|
215
|
+
chat4appMessage.data.all = datTmp;
|
|
216
|
+
chatCallback.onMessage(chat4appMessage);
|
|
217
|
+
}
|
|
218
|
+
else if ((data.type == "on" || data.type == "off")) {
|
|
219
|
+
let chat4appMessage = new Chat4AppMessageReceive();
|
|
220
|
+
chat4appMessage.data.chatId = data.chatId;
|
|
221
|
+
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
222
|
+
chat4appMessage.data.externalId = data.externalId;
|
|
223
|
+
chat4appMessage.data.fromId = data.fromId;
|
|
224
|
+
chat4appMessage.data.toId = data.toId;
|
|
225
|
+
chat4appMessage.data.dateHour = data.dateHour;
|
|
226
|
+
chat4appMessage.data.type = data.type;
|
|
227
|
+
let datTmp = new Map();
|
|
228
|
+
for (let key in data) {
|
|
229
|
+
datTmp.set(key, data[key]);
|
|
230
|
+
}
|
|
231
|
+
chat4appMessage.data.all = datTmp;
|
|
232
|
+
chatCallback.onOffline(chat4appMessage);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
connectWebsocket(chatCallback, token) {
|
|
236
|
+
this.disconnect();
|
|
237
|
+
let securityToken = this.getBearerToken();
|
|
238
|
+
this.sock = new SockJS(this.chatServer + '/stomp/gkz-stomp-endpoint?token=' + securityToken);
|
|
239
|
+
this.stompClient = Stomp.over(this.sock);
|
|
240
|
+
this.stompClient.debug = function (msg) {
|
|
241
|
+
//console.log(msg);
|
|
242
|
+
};
|
|
243
|
+
this.stompClient.connect({}, (frame) => {
|
|
244
|
+
//console.log(frame);
|
|
245
|
+
this.stompClient.subscribe('/queue/' + token, (msg) => {
|
|
246
|
+
//console.log('mensagem', msg);
|
|
247
|
+
if (msg.command == "MESSAGE") {
|
|
248
|
+
//console.log(msg)
|
|
249
|
+
let msgObj = JSON.parse(msg.body);
|
|
250
|
+
let datTmp = new Map();
|
|
251
|
+
for (let key in msgObj.data) {
|
|
252
|
+
datTmp.set(key, msgObj.data[key]);
|
|
253
|
+
}
|
|
254
|
+
msgObj.data.all = datTmp;
|
|
255
|
+
if (msgObj.data.type == "msg") {
|
|
256
|
+
chatCallback.onMessage(msgObj);
|
|
257
|
+
}
|
|
258
|
+
else if ((msgObj.data.type == "on" || msgObj.data.type == "off")) {
|
|
259
|
+
chatCallback.onOffline(msgObj);
|
|
260
|
+
}
|
|
261
|
+
//callback(msg.body);
|
|
262
|
+
// ichatcallback.forEach((iChat)=>{
|
|
263
|
+
// iChat.onMessage(JSON.parse(msg.body) );
|
|
264
|
+
// });
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}, (message) => {
|
|
268
|
+
// check message for disconnect
|
|
269
|
+
//console.log("Disconnect");
|
|
270
|
+
setTimeout(() => {
|
|
271
|
+
this.connectWebsocket(chatCallback, token);
|
|
272
|
+
}, 500);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
disconnect() {
|
|
276
|
+
// console.log("disconnect")
|
|
277
|
+
try {
|
|
278
|
+
if (this.stompClient) {
|
|
279
|
+
this.stompClient.disconnect();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
catch (e) {
|
|
283
|
+
console.log(e);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
convertChat4AppMessageReceiveToChatMessage4App(msg) {
|
|
287
|
+
let message = new ChatMessage4App();
|
|
288
|
+
message.body = msg.notification.body;
|
|
289
|
+
message.chatId = msg.data.chatId;
|
|
290
|
+
message.fromId = msg.data.fromId;
|
|
291
|
+
message.toId = msg.data.toId;
|
|
292
|
+
message.dateHourIncluded = moment.utc(msg.data.dateHour, "DD-MM-YYYY hh:mm:ss").toDate();
|
|
293
|
+
message.id = msg.data.chatMessageId;
|
|
294
|
+
if (msg.data.fileId && msg.data.fileId.length > 0) {
|
|
295
|
+
let messageFile = new ChatMessageFile4App();
|
|
296
|
+
messageFile.id = msg.data.fileId;
|
|
297
|
+
messageFile.name = msg.data.fileName;
|
|
298
|
+
messageFile.size = msg.data.fileSize;
|
|
299
|
+
messageFile.type = msg.data.fileType;
|
|
300
|
+
message.chatMessageFile = messageFile;
|
|
301
|
+
}
|
|
302
|
+
return message;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
Chat4appClientAngularService.ɵprov = i0.ɵɵdefineInjectable({ factory: function Chat4appClientAngularService_Factory() { return new Chat4appClientAngularService(i0.ɵɵinject(i1.HttpClient)); }, token: Chat4appClientAngularService, providedIn: "root" });
|
|
306
|
+
Chat4appClientAngularService.decorators = [
|
|
307
|
+
{ type: Injectable, args: [{
|
|
308
|
+
providedIn: 'root'
|
|
309
|
+
},] }
|
|
310
|
+
];
|
|
311
|
+
Chat4appClientAngularService.ctorParameters = () => [
|
|
312
|
+
{ type: HttpClient }
|
|
313
|
+
];
|
|
314
|
+
class Chat4App {
|
|
315
|
+
}
|
|
316
|
+
class ChatUser4App {
|
|
317
|
+
}
|
|
318
|
+
class ChatMessage4App {
|
|
319
|
+
}
|
|
320
|
+
class ChatMessageFile4App {
|
|
321
|
+
}
|
|
322
|
+
class ChatMessageMeta4App {
|
|
323
|
+
}
|
|
324
|
+
class Chat4AppMessageReceive {
|
|
325
|
+
constructor() {
|
|
326
|
+
this.data = new Chat4AppMessageReceiveData();
|
|
327
|
+
this.notification = new Chat4AppMessageReceiveNotification();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
class Chat4AppMessageReceiveData {
|
|
331
|
+
}
|
|
332
|
+
class Chat4AppMessageReceiveNotification {
|
|
333
|
+
}
|
|
334
|
+
class ChatUserResponse4App {
|
|
335
|
+
}
|
|
336
|
+
class ChatFilterRequest4App {
|
|
337
|
+
}
|
|
338
|
+
class Chat4AppConfig {
|
|
339
|
+
constructor(endpoint) {
|
|
340
|
+
this.endpoint = endpoint;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
var ChatStatus4App;
|
|
344
|
+
(function (ChatStatus4App) {
|
|
345
|
+
ChatStatus4App["CREATED"] = "CREATED";
|
|
346
|
+
ChatStatus4App["CLOSED"] = "CLOSED";
|
|
347
|
+
})(ChatStatus4App || (ChatStatus4App = {}));
|
|
348
|
+
var ChatUserStatus4App;
|
|
349
|
+
(function (ChatUserStatus4App) {
|
|
350
|
+
ChatUserStatus4App["REMOVED"] = "REMOVED";
|
|
351
|
+
})(ChatUserStatus4App || (ChatUserStatus4App = {}));
|
|
352
|
+
var ChatFilterType;
|
|
353
|
+
(function (ChatFilterType) {
|
|
354
|
+
ChatFilterType[ChatFilterType["COUNT_NOT_READ"] = 1] = "COUNT_NOT_READ";
|
|
355
|
+
ChatFilterType[ChatFilterType["LAST_MESSAGE"] = 2] = "LAST_MESSAGE";
|
|
357
356
|
})(ChatFilterType || (ChatFilterType = {}));
|
|
358
357
|
|
|
359
|
-
class Chat4appClientAngularComponent {
|
|
360
|
-
constructor() { }
|
|
361
|
-
ngOnInit() {
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
Chat4appClientAngularComponent.decorators = [
|
|
365
|
-
{ type: Component, args: [{
|
|
366
|
-
selector: 'lib-chat4app-client-angular',
|
|
358
|
+
class Chat4appClientAngularComponent {
|
|
359
|
+
constructor() { }
|
|
360
|
+
ngOnInit() {
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
Chat4appClientAngularComponent.decorators = [
|
|
364
|
+
{ type: Component, args: [{
|
|
365
|
+
selector: 'lib-chat4app-client-angular',
|
|
367
366
|
template: `
|
|
368
367
|
<p>
|
|
369
368
|
chat4app-client-angular works!
|
|
370
369
|
</p>
|
|
371
|
-
`
|
|
372
|
-
},] }
|
|
373
|
-
];
|
|
370
|
+
`
|
|
371
|
+
},] }
|
|
372
|
+
];
|
|
374
373
|
Chat4appClientAngularComponent.ctorParameters = () => [];
|
|
375
374
|
|
|
376
|
-
class Chat4appClientAngularModule {
|
|
377
|
-
}
|
|
378
|
-
Chat4appClientAngularModule.decorators = [
|
|
379
|
-
{ type: NgModule, args: [{
|
|
380
|
-
declarations: [Chat4appClientAngularComponent],
|
|
381
|
-
imports: [],
|
|
382
|
-
exports: [Chat4appClientAngularComponent]
|
|
383
|
-
},] }
|
|
375
|
+
class Chat4appClientAngularModule {
|
|
376
|
+
}
|
|
377
|
+
Chat4appClientAngularModule.decorators = [
|
|
378
|
+
{ type: NgModule, args: [{
|
|
379
|
+
declarations: [Chat4appClientAngularComponent],
|
|
380
|
+
imports: [],
|
|
381
|
+
exports: [Chat4appClientAngularComponent]
|
|
382
|
+
},] }
|
|
384
383
|
];
|
|
385
384
|
|
|
386
|
-
/*
|
|
387
|
-
* Public API Surface of chat4app-client-angular
|
|
385
|
+
/*
|
|
386
|
+
* Public API Surface of chat4app-client-angular
|
|
388
387
|
*/
|
|
389
388
|
|
|
390
|
-
/**
|
|
391
|
-
* Generated bundle index. Do not edit.
|
|
389
|
+
/**
|
|
390
|
+
* Generated bundle index. Do not edit.
|
|
392
391
|
*/
|
|
393
392
|
|
|
394
393
|
export { Chat4App, Chat4AppConfig, Chat4AppMessageReceive, Chat4AppMessageReceiveData, Chat4AppMessageReceiveNotification, Chat4appClientAngularComponent, Chat4appClientAngularModule, Chat4appClientAngularService, ChatFilterRequest4App, ChatFilterType, ChatMessage4App, ChatMessageFile4App, ChatMessageMeta4App, ChatStatus4App, ChatUser4App, ChatUserResponse4App, ChatUserStatus4App };
|