Browse Source

export msg type

Paul 4 years ago
parent
commit
dd8b0feadb

+ 1
- 0
packages/cts-api/src/index.ts View File

@@ -1,2 +1,3 @@
1 1
 export { WsApi } from './api/WsApi';
2 2
 export { WebSocketClient } from './WebSocketClient';
3
+export {MsgType, ChatType} from './protocol/MsgBase'

+ 1
- 1
packages/cts-api/src/protocol/AttachmentMsg.ts View File

@@ -1,7 +1,7 @@
1 1
 import { MsgBase, MsgType } from './MsgBase';
2 2
 
3 3
 export class AttachmentMsg extends MsgBase {
4
-  type: MsgType = 'attachment';
4
+  msgType: MsgType = 'attachment';
5 5
 
6 6
   // 消息内容
7 7
   msg: string;

+ 2
- 15
packages/cts-api/src/protocol/MsgBase.ts View File

@@ -2,17 +2,7 @@ import { uuid } from '../utils/uuid';
2 2
 
3 3
 export type MsgType = 'text' | 'media' | 'cmd' | 'attachment';
4 4
 
5
-export type RoomType = 'single' | 'room';
6
-
7
-export type GroupOption = {
8
-  subject: string; // 群名称
9
-  description: string; // 群简介
10
-  members: string[]; // 成员列表
11
-  optionsPublic: boolean; // 允许任何人加入
12
-  optionsModerate: boolean; // 加入需审批
13
-  optionsMembersOnly: boolean; // 不允许任何人主动加入
14
-  optionsAllowInvites: boolean; // 允许群人员邀请
15
-};
5
+export type ChatType = 'chat' | 'room' | 'group' | 'push';
16 6
 
17 7
 export class MsgBase {
18 8
   // 消息编号
@@ -24,11 +14,8 @@ export class MsgBase {
24 14
   // 消息接收方/目标方,如果是发送给多个人,则用 , 逗号分隔
25 15
   to: string;
26 16
 
27
-  // 消息类型
28
-  type: MsgType;
29
-
30 17
   // 聊天室类型
31
-  roomType: RoomType;
18
+  type: ChatType;
32 19
 
33 20
   // 扩展消息
34 21
   ext: Record<string, string>;

+ 1
- 1
packages/cts-api/src/protocol/TextMsg.ts View File

@@ -1,7 +1,7 @@
1 1
 import { MsgBase, MsgType } from './MsgBase';
2 2
 
3 3
 export class TextMsg extends MsgBase {
4
-  type: MsgType = 'text';
4
+  msgType: MsgType = 'text';
5 5
 
6 6
   // 消息内容
7 7
   msg: string;