add other messaging types for finer control
This commit is contained in:
parent
e7a64d07f4
commit
728bf33856
1 changed files with 33 additions and 0 deletions
|
@ -4,8 +4,41 @@ export enum MessageType {
|
||||||
HELLO,
|
HELLO,
|
||||||
DATA,
|
DATA,
|
||||||
}
|
}
|
||||||
export type Message = {
|
export enum SystemMessageCode {
|
||||||
type: MessageType,
|
REQ,
|
||||||
|
RES,
|
||||||
|
ERR,
|
||||||
|
}
|
||||||
|
export type HistoryFetchResult = {
|
||||||
|
count: number,
|
||||||
|
items: Array<ChatMessage>,
|
||||||
|
}
|
||||||
|
export type ErrorResult = {
|
||||||
|
text: string,
|
||||||
|
}
|
||||||
|
export type TimestampSendRequest = {
|
||||||
|
ts: number,
|
||||||
|
}
|
||||||
|
export type SystemMessage = {
|
||||||
|
code: SystemMessageCode
|
||||||
|
data: HistoryFetchResult | ErrorResult | TimestampSendRequest
|
||||||
|
}
|
||||||
|
export type ChatMessage = {
|
||||||
|
fromUserId: string,
|
||||||
|
toUserId: string,
|
||||||
|
content: string,
|
||||||
|
timeMillis: number
|
||||||
|
}
|
||||||
|
export type HelloMessage = {
|
||||||
|
fromUserId: string,
|
||||||
|
timeMillis: number,
|
||||||
|
}
|
||||||
|
export type DataMessage = {
|
||||||
|
|
||||||
|
}
|
||||||
|
export type Message = {
|
||||||
|
type: MessageType,
|
||||||
|
// data: SystemMessage | ChatMessage | HelloMessage
|
||||||
fromUserId: string,
|
fromUserId: string,
|
||||||
toUserId: string,
|
toUserId: string,
|
||||||
content: string,
|
content: string,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue