Skip to content

Commit

Permalink
docs: add common type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiu8081 committed Sep 26, 2022
1 parent 8260fca commit 9a1b912
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,25 @@ instance.close()
### Common

```ts
const startListen: (roomId: number, handler: MsgHandler) => MessageListener

export interface MessageListener {
/** 直播间房间号 */
roomId: number
/** 关闭连接 */
close: () => void
/** 刷新当前直播间热度 */
getAttention: () => Promise<number>
}

export interface Message<T> {
/** 消息id */
id: string,
/** 接收消息的时间,毫秒时间戳 */
timestamp: number,
/** 消息类型 */
type: string,
/** 消息内容 */
body: T
}

Expand Down
8 changes: 4 additions & 4 deletions src/types/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ export enum GuardLevel {
}

export interface Message<T> {
/** 消息id */
id: string,
/** 接收消息的时间,毫秒时间戳 */
timestamp: number,
/** 消息类型 */
type: string,
/** 消息内容 */
body: T
}

export interface BaseMsg {
user: User
}

0 comments on commit 9a1b912

Please sign in to comment.