聊天会话记录
This commit is contained in:
@@ -26,15 +26,25 @@ export default class HttpApi {
|
||||
|
||||
let requestMethod = "POST";
|
||||
|
||||
// 讲appid等参数写入body
|
||||
body=this.setQueryToBody(params,body);
|
||||
|
||||
const headers = {
|
||||
'Content-Type':'application/json',
|
||||
};
|
||||
|
||||
|
||||
const request: any = {method: requestMethod,headers:headers, mode: 'cors', body: Beans.json(body)};
|
||||
return this.httpFetch(reqUrl, request);
|
||||
|
||||
}
|
||||
|
||||
setQueryToBody(params:any,body:any){
|
||||
for(const o in params){
|
||||
body[o] = params[o];
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
setQueryConfig(params:any){
|
||||
var _str = "?";
|
||||
for(const o in params){
|
||||
|
||||
@@ -69,8 +69,8 @@ export class ImClient {
|
||||
userSign!: string;
|
||||
imeiLength?: number
|
||||
state = State.INIT
|
||||
// lastOfflineMessageSequence: number = 0;
|
||||
// offlineMessageList: Array<any> = new Array<any>()
|
||||
lastOfflineMessageSequence: number = 0;
|
||||
offlineMessageList: Array<any> = new Array<any>()
|
||||
httpUrl: string = ""//http://127.0.0.1:8000/v1
|
||||
|
||||
private conn?: w3cwebsocket
|
||||
@@ -171,7 +171,7 @@ export class ImClient {
|
||||
this.conn = conn;
|
||||
this.state = State.CONNECTED
|
||||
//拉取离线消息
|
||||
// this.loadOfflineMessage();
|
||||
this.loadOfflineMessage();
|
||||
//心跳包
|
||||
this.heartbeatLoop(this.conn);
|
||||
|
||||
@@ -292,7 +292,7 @@ export class ImClient {
|
||||
public getUserConversationList(lastSequence:Long): Promise<any> {
|
||||
return new Promise((resolve, _) => {
|
||||
let api = new HttpApi(this.httpUrl);
|
||||
let resp = api.call("/conversation/syncConversationList", this.getRequestParams(), { userId: this.userId,appId:this.appId,maxLimit:100, lastSequence:lastSequence })
|
||||
let resp = api.call("/conversation/syncConversationList", this.getRequestParams(), { userId: this.userId,appId:this.appId,maxLimit:100, lastSequence:lastSequence,operater:this.userId })
|
||||
resolve(resp);
|
||||
})
|
||||
}
|
||||
@@ -336,25 +336,26 @@ export class ImClient {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
// private async loadOfflineMessage() {
|
||||
// log.info("loadOfflineMessage start")
|
||||
// let api = new HttpApi(this.httpUrl);
|
||||
// let resp = await api.call("/message/syncOfflineMessage",this.getRequestParams(),{clientType : this.clientType,appId : this.appId,lastSequence:this.lastOfflineMessageSequence,maxLimit:100})
|
||||
// if(resp.isSucceed()){
|
||||
// this.lastOfflineMessageSequence = resp.data.maxSequence;
|
||||
// let offmessages = resp.data.dataList;
|
||||
// this.offlineMessageList.push(offmessages)
|
||||
// if(offmessages.length > 0 && typeof imClient.listeners.onOfflineMessage === 'function'){
|
||||
// imClient.listeners.onOfflineMessage(offmessages);
|
||||
// }
|
||||
// console.log(resp.data.completed)
|
||||
// if(!resp.data.completed){
|
||||
// this.loadOfflineMessage();
|
||||
// }
|
||||
// }else{
|
||||
// log.error("loadOfflineMessage - error")
|
||||
// }
|
||||
// }
|
||||
//拉取离线信息记录
|
||||
private async loadOfflineMessage() {
|
||||
log.info("loadOfflineMessage start")
|
||||
let api = new HttpApi(this.httpUrl);
|
||||
let resp = await api.call("/message/syncOfflineMessage",this.getRequestParams(),{clientType : this.clientType,operater:this.userId, appId : this.appId,lastSequence:this.lastOfflineMessageSequence,maxLimit:100})
|
||||
if(resp.isSucceed()){
|
||||
this.lastOfflineMessageSequence = resp.data.maxSequence;
|
||||
let offmessages = resp.data.dataList;
|
||||
this.offlineMessageList.push(offmessages)
|
||||
if(offmessages.length > 0 && typeof imClient.listeners.onOfflineMessage === 'function'){
|
||||
imClient.listeners.onOfflineMessage(offmessages);
|
||||
}
|
||||
console.log(resp.data.completed)
|
||||
if(!resp.data.completed){
|
||||
this.loadOfflineMessage();
|
||||
}
|
||||
}else{
|
||||
log.error("loadOfflineMessage - error")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user