Authored by 姜枫

处理sessionId

@@ -583,16 +583,27 @@ function pageInit() { @@ -583,16 +583,27 @@ function pageInit() {
583 * 连接socket 583 * 连接socket
584 */ 584 */
585 function connectSocket() { 585 function connectSocket() {
586 - socketChat.init(Object.assign(originConf, { 586 +
  587 + // 获取上次会话id
  588 + var lastSessionId = window.cookie('sessionId');
  589 +
  590 + originConf.conversationMessage.sessionId = lastSessionId || 0;
  591 + socketChat.init(Object.assign(originConf, {
587 onMessage: function onMessage(e) { 592 onMessage: function onMessage(e) {
588 var jsonString = e.data; 593 var jsonString = e.data;
589 var received = JSON.parse(jsonString); 594 var received = JSON.parse(jsonString);
590 595
591 socketConfCM.conversationId = received.newConversationId !== 0 ? received.newConversationId : received.conversationId; 596 socketConfCM.conversationId = received.newConversationId !== 0 ? received.newConversationId : received.conversationId;
592 597
  598 + // 保存会话id
  599 + window.setCookie('conversationId', socketConfCM.conversationId, {expires: 60 * 15});
  600 + window.setCookie('sessionId', received.sessionId, {expires: 60 * 15});
593 getMessage(received); 601 getMessage(received);
594 }, 602 },
595 603
  604 + onOpen: function onClose(e) {
  605 + },
  606 +
596 onClose: function onClose() { 607 onClose: function onClose() {
597 $('.connect-fail').fadeIn(); 608 $('.connect-fail').fadeIn();
598 }, 609 },
@@ -102,6 +102,7 @@ function closeSocket() { @@ -102,6 +102,7 @@ function closeSocket() {
102 } 102 }
103 103
104 module.exports = { 104 module.exports = {
  105 + socket: socket,
105 init: socketInit, 106 init: socketInit,
106 close: closeSocket, 107 close: closeSocket,
107 send: sendMsg 108 send: sendMsg