客户端sdk更新

This commit is contained in:
2023-10-26 16:39:53 +08:00
parent d1037b461f
commit ef937b433a
3 changed files with 43 additions and 3 deletions

View File

@@ -112,7 +112,18 @@ export class ImClient {
}
let ip = resp.data.ip;
let port = resp.data.port;
this.url = "wss://" + ip + ":" + port + "/hs_ws";
var protocolStr = document.location.protocol;
if(protocolStr == "http:")
{
this.url = "ws://" + ip + ":" + port + "/ws";
}
else if(protocolStr == "https:")
{
this.url = "wss://" + ip + "/hs_ws";
}
}
var req = new LoginPack(self.appId, self.userId, 1);
@@ -254,6 +265,7 @@ export class ImClient {
}
}
public getSingleUserInfo(uid: string): Promise<any> {
return new Promise((resolve, _) => {
let api = new HttpApi(this.httpUrl);
@@ -262,6 +274,7 @@ export class ImClient {
})
}
public async syncGetUserInfo(userId: string[]) {
let api = new HttpApi(this.httpUrl);
let resp = api.call("/user/data/getUserInfo", this.getRequestParams(), { userIds: userId })
@@ -301,6 +314,30 @@ export class ImClient {
})
}
public createRoom(room:any): Promise<any> {
return new Promise((resolve,_)=>{
let api = new HttpApi(this.httpUrl);
let resp = api.call("/room/createRoom", this.getRequestParams(), room)
return resp;
})
}
public joinRoom(room:any): Promise<any> {
return new Promise((resolve,_)=>{
let api = new HttpApi(this.httpUrl);
let resp = api.call("/room/joinRoom", this.getRequestParams(), room)
return resp;
})
}
public getRoomInfo(roomId:any): Promise<any> {
return new Promise((resolve,_)=>{
let api = new HttpApi(this.httpUrl);
let resp = api.call("/room/getRoomInfo", this.getRequestParams(), { roomId: roomId })
return resp;
})
}
// 2、心跳
private heartbeatLoop(conn) {
let start = Date.now()