podchat-browser 12.7.2-snapshot.2 → 12.7.2-snapshot.21
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/dist/node/call.module.js +615 -403
- package/dist/node/chat.js +246 -80
- package/dist/node/lib/constants.js +1 -1
- package/dist/node/lib/errorHandler.js +4 -0
- package/dist/node/lib/store/eventEmitter.js +24 -0
- package/dist/node/lib/store/index.js +16 -0
- package/dist/node/lib/store/threads.js +121 -0
- package/dist/node/messaging.module.js +28 -9
- package/dist/podchat-browser-bundle.js +782 -239
- package/examples/index.html +7 -3
- package/package.json +2 -2
- package/src/call.module.js +228 -108
- package/src/chat.js +371 -288
- package/src/lib/constants.js +1 -1
- package/src/lib/errorHandler.js +4 -0
- package/src/lib/store/eventEmitter.js +16 -0
- package/src/lib/store/index.js +9 -0
- package/src/lib/store/threads.js +99 -0
- package/src/messaging.module.js +22 -6
|
@@ -33,7 +33,6 @@ var chatMessageVOTypes = {
|
|
|
33
33
|
THREAD_PARTICIPANTS: 27,
|
|
34
34
|
EDIT_MESSAGE: 28,
|
|
35
35
|
DELETE_MESSAGE: 29,
|
|
36
|
-
THREAD_INFO_UPDATED: 30,
|
|
37
36
|
LAST_SEEN_UPDATED: 31,
|
|
38
37
|
GET_MESSAGE_DELIVERY_PARTICIPANTS: 32,
|
|
39
38
|
GET_MESSAGE_SEEN_PARTICIPANTS: 33,
|
|
@@ -131,6 +130,7 @@ var chatMessageVOTypes = {
|
|
|
131
130
|
CALL_STICKER_SYSTEM_MESSAGE: 225,
|
|
132
131
|
CUSTOMER_INFO: 226,
|
|
133
132
|
RECALL_THREAD_PARTICIPANT: 227,
|
|
133
|
+
CALL_RECORDING_FAILED: 230,
|
|
134
134
|
ERROR: 999
|
|
135
135
|
};
|
|
136
136
|
exports.chatMessageVOTypes = chatMessageVOTypes;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.storeEvents = void 0;
|
|
9
|
+
|
|
10
|
+
var _events = _interopRequireDefault(require("events"));
|
|
11
|
+
|
|
12
|
+
var Emitter = new _events["default"]();
|
|
13
|
+
var storeEvents = {
|
|
14
|
+
on: function on(eventName, callback) {
|
|
15
|
+
Emitter.on(eventName, callback);
|
|
16
|
+
},
|
|
17
|
+
off: function off(eventName) {
|
|
18
|
+
Emitter.off(eventName);
|
|
19
|
+
},
|
|
20
|
+
emit: function emit(eventName, data) {
|
|
21
|
+
Emitter.emit(eventName, data);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.storeEvents = storeEvents;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.store = void 0;
|
|
7
|
+
|
|
8
|
+
var _threads = require("./threads");
|
|
9
|
+
|
|
10
|
+
var _eventEmitter = require("./eventEmitter");
|
|
11
|
+
|
|
12
|
+
var store = {
|
|
13
|
+
threads: _threads.threadsList,
|
|
14
|
+
events: _eventEmitter.storeEvents
|
|
15
|
+
};
|
|
16
|
+
exports.store = store;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.threadsList = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _eventEmitter = require("./eventEmitter");
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
|
|
18
|
+
var list = [];
|
|
19
|
+
var eventsList = {
|
|
20
|
+
UNREAD_COUNT_UPDATED: 'unreadCountUpdated',
|
|
21
|
+
LAST_SEEN_MESSAGE_TIME_UPDATED: 'lastSeenMessageTimeUpdated'
|
|
22
|
+
};
|
|
23
|
+
var threadsList = {
|
|
24
|
+
eventsList: eventsList,
|
|
25
|
+
get: function get(id) {
|
|
26
|
+
return list[threadsList.findIndex(id)];
|
|
27
|
+
},
|
|
28
|
+
getAll: function getAll() {
|
|
29
|
+
return list;
|
|
30
|
+
},
|
|
31
|
+
findIndex: function findIndex(threadId) {
|
|
32
|
+
return list.findIndex(function (item) {
|
|
33
|
+
return (item === null || item === void 0 ? void 0 : item.get().id) == threadId;
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
save: function save(thread) {
|
|
37
|
+
var localThreadIndex = threadsList.findIndex(thread.id);
|
|
38
|
+
|
|
39
|
+
if (localThreadIndex > -1) {
|
|
40
|
+
list[localThreadIndex].set(thread);
|
|
41
|
+
} else {
|
|
42
|
+
list = [new ThreadObject(thread)].concat(list);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
saveMany: function saveMany(newThreads) {
|
|
46
|
+
if (Array.isArray(newThreads)) {
|
|
47
|
+
var nonExistingThreads = [];
|
|
48
|
+
|
|
49
|
+
for (var item in newThreads) {
|
|
50
|
+
var localThreadIndex = threadsList.findIndex(newThreads[item].id);
|
|
51
|
+
|
|
52
|
+
if (localThreadIndex > -1) {
|
|
53
|
+
list[localThreadIndex].set(newThreads[item]);
|
|
54
|
+
} else {
|
|
55
|
+
nonExistingThreads.push(new ThreadObject(newThreads[item]));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (nonExistingThreads.length) {
|
|
60
|
+
list = nonExistingThreads.concat(list);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
remove: function remove(id) {
|
|
65
|
+
var localThreadIndex = threadsList.findIndex(id);
|
|
66
|
+
|
|
67
|
+
if (localThreadIndex > -1) {
|
|
68
|
+
delete list[localThreadIndex];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.threadsList = threadsList;
|
|
73
|
+
|
|
74
|
+
function ThreadObject(thread) {
|
|
75
|
+
var config = {
|
|
76
|
+
thread: thread
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
set: function set(thread) {
|
|
80
|
+
config.thread = _objectSpread(_objectSpread({}, config.thread), thread);
|
|
81
|
+
},
|
|
82
|
+
get: function get() {
|
|
83
|
+
return config.thread;
|
|
84
|
+
},
|
|
85
|
+
update: function update(field, newValue) {
|
|
86
|
+
config.thread[field] = newValue;
|
|
87
|
+
},
|
|
88
|
+
unreadCount: {
|
|
89
|
+
set: function set(count) {
|
|
90
|
+
config.thread.unreadCount = count;
|
|
91
|
+
|
|
92
|
+
_eventEmitter.storeEvents.emit(eventsList.UNREAD_COUNT_UPDATED, config.thread);
|
|
93
|
+
},
|
|
94
|
+
get: function get() {
|
|
95
|
+
return config.thread.unreadCount;
|
|
96
|
+
},
|
|
97
|
+
increase: function increase() {
|
|
98
|
+
config.thread.unreadCount++;
|
|
99
|
+
|
|
100
|
+
_eventEmitter.storeEvents.emit(eventsList.UNREAD_COUNT_UPDATED, config.thread);
|
|
101
|
+
},
|
|
102
|
+
decrease: function decrease(time) {
|
|
103
|
+
if (time > config.thread.lastSeenMessageTime && config.thread.unreadCount > 0) {
|
|
104
|
+
config.thread.unreadCount--;
|
|
105
|
+
|
|
106
|
+
_eventEmitter.storeEvents.emit(eventsList.UNREAD_COUNT_UPDATED, config.thread);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
lastSeenMessageTime: {
|
|
111
|
+
set: function set(number) {
|
|
112
|
+
if (number > config.thread.lastSeenMessageTime) {
|
|
113
|
+
config.thread.lastSeenMessageTime = number;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
get: function get() {
|
|
117
|
+
return config.thread.lastSeenMessageTime;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -40,10 +40,25 @@ function ChatMessaging(params) {
|
|
|
40
40
|
this.threadCallbacks = {};
|
|
41
41
|
this.sendMessageCallbacks = {};
|
|
42
42
|
this.messagesCallbacks = {};
|
|
43
|
-
this.asyncRequestTimeouts = {};
|
|
44
|
-
|
|
43
|
+
this.asyncRequestTimeouts = {}; // this.sendPingTimeout = null;
|
|
44
|
+
|
|
45
45
|
this.chatState = false;
|
|
46
46
|
this.userInfo = null;
|
|
47
|
+
/**
|
|
48
|
+
* sendPingTimeout removed,
|
|
49
|
+
*
|
|
50
|
+
* TODO: remove the interval when socket statet changes to closed
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
this.startChatPing = function () {
|
|
54
|
+
chatPingMessageInterval = setInterval(function () {
|
|
55
|
+
currentModuleInstance.ping();
|
|
56
|
+
}, 20000); //TODO: chatPingMessageInterval
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
this.stopChatPing = function () {
|
|
60
|
+
clearInterval(chatPingMessageInterval);
|
|
61
|
+
};
|
|
47
62
|
|
|
48
63
|
this.asyncInitialized = function (client) {
|
|
49
64
|
asyncClient = client;
|
|
@@ -233,7 +248,8 @@ function ChatMessaging(params) {
|
|
|
233
248
|
priority: asyncPriority,
|
|
234
249
|
content: JSON.stringify(messageVO),
|
|
235
250
|
ttl: params.messageTtl > 0 ? params.messageTtl : messageTtl
|
|
236
|
-
}
|
|
251
|
+
},
|
|
252
|
+
uniqueId: messageVO.uniqueId
|
|
237
253
|
};
|
|
238
254
|
asyncClient.send(data, function (res) {
|
|
239
255
|
if (!res.hasError && callbacks) {
|
|
@@ -280,11 +296,12 @@ function ChatMessaging(params) {
|
|
|
280
296
|
}
|
|
281
297
|
}, asyncRequestTimeout);
|
|
282
298
|
}
|
|
299
|
+
/* currentModuleInstance.sendPingTimeout && clearTimeout(currentModuleInstance.sendPingTimeout);
|
|
300
|
+
currentModuleInstance.sendPingTimeout = setTimeout(function () {
|
|
301
|
+
currentModuleInstance.ping();
|
|
302
|
+
}, chatPingMessageInterval); */
|
|
303
|
+
|
|
283
304
|
|
|
284
|
-
currentModuleInstance.sendPingTimeout && clearTimeout(currentModuleInstance.sendPingTimeout);
|
|
285
|
-
currentModuleInstance.sendPingTimeout = setTimeout(function () {
|
|
286
|
-
currentModuleInstance.ping();
|
|
287
|
-
}, chatPingMessageInterval);
|
|
288
305
|
recursiveCallback && recursiveCallback();
|
|
289
306
|
return {
|
|
290
307
|
uniqueId: uniqueId,
|
|
@@ -316,9 +333,11 @@ function ChatMessaging(params) {
|
|
|
316
333
|
chatMessageVOType: _constants.chatMessageVOTypes.PING,
|
|
317
334
|
pushMsgType: 3
|
|
318
335
|
});
|
|
319
|
-
} else {
|
|
320
|
-
currentModuleInstance.sendPingTimeout && clearTimeout(currentModuleInstance.sendPingTimeout);
|
|
321
336
|
}
|
|
337
|
+
/*else {
|
|
338
|
+
currentModuleInstance.sendPingTimeout && clearTimeout(currentModuleInstance.sendPingTimeout);
|
|
339
|
+
}*/
|
|
340
|
+
|
|
322
341
|
};
|
|
323
342
|
} // if (typeof module !== 'undefined' && typeof module.exports != 'undefined') {
|
|
324
343
|
// module.exports = ChatMessaging;
|