Commit d5af68b7 by panjiangyi

token接入

parent f5dd8918
Showing with 3 additions and 19 deletions
......@@ -31,14 +31,6 @@ export type TokenStringGetter = () => Promise<string>
export interface ChatOption {
/**
* 企业token [商户端使用,用户端和移动端不需要]
*/
enterpriseTokenString?: TokenStringGetter;
/**
* 个人token
*/
userTokenString: TokenStringGetter;
/**
* 长链接chat sdk地址
*/
webSocketUri: string;
......@@ -46,8 +38,6 @@ export interface ChatOption {
sdk: () => UniplatSdk;
orgId: () => string | number;
logger?: ChatServiceLogger;
}
export interface ChatServiceLogger {
......
......@@ -21,9 +21,7 @@ class Chat {
if (!option) {
throw new Error(`You must specify a chat option for chat service`);
}
// if (!option.userTokenString) {
// throw new Error(`You must specify a user token for chat service`)
// }
if (!option.webSocketUri) {
throw new Error(
`You must specify a web socket address for chat service`
......@@ -32,12 +30,8 @@ class Chat {
this._sdk = option.sdk;
this._orgId = option.orgId;
// if (option.enterpriseTokenString) {
// this.token = option.enterpriseTokenString
// } else {
this.token = option.userTokenString;
this.token = async () => option.sdk().global.jwtToken;
tokenManager.save(this.token);
// }
EmojiService.raiseOnReady(this.token);
return this.initChatSdk(option.webSocketUri);
......
......@@ -146,7 +146,7 @@ export class Xim {
): Promise<Message[]> {
this.checkConnected();
if (this.client == null) {
throw new Error("client shouldn't undefined")
throw new Error("client shouldn't undefined");
};
const res = await this.client.fetchChatMsgs(chatType, chatId, {
lid,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment