add other messaging types for finer control

This commit is contained in:
Zhongheng Liu 2024-01-03 22:28:32 +02:00
commit 728bf33856
No known key found for this signature in database

View file

@ -3,9 +3,42 @@ export enum MessageType {
SYSTEM,
HELLO,
DATA,
}
export enum SystemMessageCode {
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,
toUserId: string,
content: string,