thunbu-im-sdk
Version:
thunbu IM JSSDK
214 lines (213 loc) • 7.41 kB
TypeScript
import { IMMetaTypes } from "./Meta.i";
import { SIMTypes } from "./index.i";
/** IM 发送的参数 */
export declare namespace IMSendTypes {
type MsgPacketId = string;
/** 消息元信息 */
interface MsgMetaData {
command: IMMetaTypes.IMCommandEnum;
packetId: IMSendTypes.MsgPacketId;
}
/** 登录信息 */
interface LoginContent {
command: IMMetaTypes.IMCommandEnum.CMD_LOGIN;
appId: string;
appversion: string;
userSig: string;
userId: string;
terminal: '0' | '1';
bundleId: string;
}
/** 查询离线消息的查询类型枚举 0单聊,1群聊,2指令 */
enum QueryOfflineMsgTypeEnum {
SingleChat = 0,
GroupChat = 1,
Instruction = 2
}
/** 普通消息发送格式 */
type Send_DefaultMsg = MsgMetaData & {
/** command */
command: IMMetaTypes.IMCommandEnum.CMD_MSG;
/** 安全类型,0-普通,1-密聊 */
securityType: 0 | 1;
/** 是否跨域 */
cross: 0 | 1;
/** 消息类型 */
msgType: IMMetaTypes.SendNormalMsgTypeEnum;
/** 消息内容 */
message: string;
/** 发送者 */
sender: string;
/** 接收者 */
receiver: string;
/** 会话类型 */
chatType: SIMTypes.ChatTypeEnum;
/** 发送时间 */
time: number;
/** 群类型,可选值[0:私密群,1:公开群,2:讨论组] */
groupType?: 0 | 1 | 2;
/** 是否有离线推送 */
offlinePush?: boolean;
/** 离线推送内容 */
offlinePushInfo?: string;
/** 消息扩展字段 */
domain?: string;
};
/** 发送已读消息 */
type Send_ReadMsg = MsgMetaData & {
/** 消息类型 */
msgType: IMMetaTypes.MsgTypeEnum.Msg_Read;
command: IMMetaTypes.IMCommandEnum.CMD_MSG_READ;
chatType: SIMTypes.ChatTypeEnum;
securityType: 0 | 1;
cross: 0 | 1;
message: string;
receiver: string;
sender: string;
time: number;
};
/** 发送撤回消息 */
type Send_RevocationMsg = MsgMetaData & {
msgType: IMMetaTypes.MsgTypeEnum.Msg_Withdraw;
command: IMMetaTypes.IMCommandEnum.CMD_MSG_REVOCATION;
chatType: SIMTypes.ChatTypeEnum;
securityType: 0 | 1;
cross: 0 | 1;
message: string;
receiver: string;
sender: string;
time: number;
};
/** 获取已读状态 */
type Send_FetchMsgRead = MsgMetaData & {
msgType: IMMetaTypes.MsgTypeEnum;
command: IMMetaTypes.IMCommandEnum.CMD_MSG_GETREAD_NOTICE;
chatType: SIMTypes.ChatTypeEnum;
securityType: 0 | 1;
cross: 0 | 1;
message: string;
receiver: string;
sender: string;
time: number;
};
/** 删除消息 */
type Send_DeleteMsg = MsgMetaData & {
msgType: IMMetaTypes.MsgTypeEnum;
command: IMMetaTypes.IMCommandEnum.CMD_MSG_ADMIN_DELETE | IMMetaTypes.IMCommandEnum.CMD_MSG_DELETE;
chatType: SIMTypes.ChatTypeEnum;
securityType: 0 | 1;
cross: 0 | 1;
message: string;
receiver: string;
sender: string;
time: number;
};
/** 查询离线消息的请求包体 */
type Send_GetOffLineMsg = MsgMetaData & {
command: IMMetaTypes.IMCommandEnum.CMD_OFFLINE_MSG_INQUIRE;
lastMsgTime?: number;
loginTime?: number;
tId?: string;
queryType: QueryOfflineMsgTypeEnum;
};
/** 发送音视频事件 */
type Send_VVCEventMsg = MsgMetaData & {
command: IMMetaTypes.IMCommandEnum.CMD_MSG_AV;
sender: string;
method: SIMTypes.VVCEventMethod;
cross: 0 | 1;
conId?: string;
communicateType?: number;
version?: string;
overTimes?: number;
receiver?: string;
uniqueId?: string;
};
type Send_InitMsgCount = MsgMetaData & {
command: IMMetaTypes.IMCommandEnum.CMD_CHAT_MSG_COUNT_SET;
chatId: string;
chatType: SIMTypes.ChatTypeEnum;
securityType: 0 | 1;
time?: number;
};
/** 登录消息体 */
type Send_LoginMsg = MsgMetaData & LoginContent & {
command: IMMetaTypes.IMCommandEnum.CMD_LOGIN;
};
type Send_LogoutMsg = MsgMetaData & {};
/** 心跳消息体 */
type Send_HeartBeatMsg = MsgMetaData & {
command: IMMetaTypes.IMCommandEnum.CMD_HB;
};
/** 回执 */
type Send_ReceiptMsg = MsgMetaData & {
userId: string;
command: IMMetaTypes.IMCommandEnum.CMD_MSG_C_RES;
};
/** 发送的消息体类型集合 */
type Send_MsgTypeCorrespondMap = {
[]: Send_HeartBeatMsg;
[]: Send_LoginMsg;
[]: Send_LogoutMsg;
[]: Send_ReceiptMsg;
[]: Send_DefaultMsg;
[]: Send_ReadMsg;
[]: Send_RevocationMsg;
[]: Send_FetchMsgRead;
[]: Send_DeleteMsg;
[]: Send_DeleteMsg;
[]: Send_GetOffLineMsg;
[]: Send_VVCEventMsg;
[]: Send_InitMsgCount;
};
/** _sendMsg 可以发送的消息 */
type Send_MsgItem<T extends keyof Send_MsgTypeCorrespondMap> = Send_MsgTypeCorrespondMap[T];
}
/** IM 收到的消息体 */
export declare namespace IMReceiveTypes {
type MsgMetaData = IMSendTypes.MsgMetaData;
/** 服务端的回执内容 */
interface ReceiptMsg_Basic<T = any> extends IMSendTypes.MsgMetaData {
data?: T;
result?: IMMetaTypes.IM_Status;
message?: string;
}
/** todo 普通消息 消息体 */
interface DefaultMsg extends MsgMetaData {
"appId": string;
"time": string;
"cross": boolean;
"message": string;
"msgType": number;
"sender": string;
"receiver": string;
"chatType": number;
"securityType": number;
"sign": boolean;
"signUser": string;
"delFlag": boolean;
"priDelFlag": boolean;
"admDelFlag": boolean;
"readedFlag": boolean;
"offlinePush": boolean;
"varStatus": number;
"replyCount": number;
"readed": boolean;
"pReaded": number;
"pAll": number;
"serialId": string;
"tid": string;
}
interface MsgChangeBody extends DefaultMsg {
}
interface CdMsgBody extends DefaultMsg {
}
/** todo 通知消息 */
interface Notice extends MsgMetaData {
ext: any;
type?: number;
}
interface QueryOfflineMsgResult extends MsgMetaData {
data: DefaultMsg[];
}
}