|
@@ -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
|
},
|