...
|
...
|
@@ -583,16 +583,27 @@ function pageInit() { |
|
|
* 连接socket
|
|
|
*/
|
|
|
function connectSocket() {
|
|
|
socketChat.init(Object.assign(originConf, {
|
|
|
|
|
|
// 获取上次会话id
|
|
|
var lastSessionId = window.cookie('sessionId');
|
|
|
|
|
|
originConf.conversationMessage.sessionId = lastSessionId || 0;
|
|
|
socketChat.init(Object.assign(originConf, {
|
|
|
onMessage: function onMessage(e) {
|
|
|
var jsonString = e.data;
|
|
|
var received = JSON.parse(jsonString);
|
|
|
|
|
|
socketConfCM.conversationId = received.newConversationId !== 0 ? received.newConversationId : received.conversationId;
|
|
|
|
|
|
// 保存会话id
|
|
|
window.setCookie('conversationId', socketConfCM.conversationId, {expires: 60 * 15});
|
|
|
window.setCookie('sessionId', received.sessionId, {expires: 60 * 15});
|
|
|
getMessage(received);
|
|
|
},
|
|
|
|
|
|
onOpen: function onClose(e) {
|
|
|
},
|
|
|
|
|
|
onClose: function onClose() {
|
|
|
$('.connect-fail').fadeIn();
|
|
|
},
|
...
|
...
|
|