|
|
package entities
|
|
|
|
|
|
type ClientMessage struct {
|
|
|
RequestID string `json:"rid,omitempty"`
|
|
|
}
|
|
|
|
|
|
type ClientInitMessage struct {
|
|
|
ClientMessage
|
|
|
Room string `json:"room"`
|
|
|
}
|
|
|
|
|
|
type ClientJoinMessage struct {
|
|
|
ClientMessage
|
|
|
Username string `json:"username,omitempty"`
|
|
|
Room string `json:"room,omitempty"`
|
|
|
Password string `json:"password,omitempty"`
|
|
|
}
|
|
|
|
|
|
type ClientSetUrlMessage struct {
|
|
|
ClientMessage
|
|
|
VideoUrls []string `json:"videoUrls,omitempty"`
|
|
|
}
|
|
|
|
|
|
type ClientSetTimeMessage struct {
|
|
|
ClientMessage
|
|
|
PlayTime int64 `json:"playTime,omitempty"`
|
|
|
}
|
|
|
|
|
|
type ClientUpdateUserStateMessage struct {
|
|
|
ClientMessage
|
|
|
PlayTime int64 `json:"playTime,omitempty"`
|
|
|
Playing bool `json:"playing,omitempty"`
|
|
|
}
|
|
|
|
|
|
type ClientDanmakuMessage struct {
|
|
|
ClientMessage
|
|
|
Text string `json:"text,omitempty"`
|
|
|
Type int `json:"type,omitempty"` // 弹幕类型,1-滚动,2-顶部,3-底部
|
|
|
Color int `json:"color,omitempty"` // 弹幕颜色,对应16进制颜色值,如白色为0xFFFFFF
|
|
|
}
|
|
|
|
|
|
type ResponseMessage struct {
|
|
|
RequestID string `json:"rid,omitempty"`
|
|
|
Code int `json:"code,omitempty"` // 200 for success
|
|
|
Message string `json:"message,omitempty"`
|
|
|
Data any `json:"data,omitempty"`
|
|
|
}
|
|
|
|
|
|
type ServerMessage struct {
|
|
|
Type string `json:"type,omitempty"` // "roomInfo", "stateChanged", etc.
|
|
|
}
|
|
|
|
|
|
type RoomStateChangedMessage struct {
|
|
|
Type string `json:"type,omitempty"` // "roomInfo", "stateChanged", etc.
|
|
|
ServerTime int64 `json:"serverTime,omitempty"`
|
|
|
VideoUrls []string `json:"videoUrls,omitempty"`
|
|
|
PlayTime int64 `json:"playTime,omitempty"`
|
|
|
Playing bool `json:"playing,omitempty"`
|
|
|
UserList []UserStatus `json:"userList,omitempty"`
|
|
|
}
|
|
|
|
|
|
type UserJoinLeaveMessage struct {
|
|
|
Type string `json:"type,omitempty"` // "userJoin", "userLeave"
|
|
|
UserInfo UserStatus `json:"userInfo,omitempty"` // User information
|
|
|
}
|
|
|
|
|
|
type UserActionMessage struct {
|
|
|
Type string `json:"type,omitempty"` // "play", "pause"
|
|
|
FromUser UserStatus `json:"fromUser,omitempty"` // User who set the time
|
|
|
}
|
|
|
|
|
|
type SetTimeMessage struct {
|
|
|
Type string `json:"type"`
|
|
|
PlayTime int64 `json:"playTime"`
|
|
|
FromUser UserStatus `json:"fromUser"`
|
|
|
}
|
|
|
|
|
|
type ServerNotificationMessage struct {
|
|
|
Type string `json:"type,omitempty"` // "message"
|
|
|
Severity string `json:"severity,omitempty"` // "info", "warning", "error"
|
|
|
Message string `json:"message,omitempty"` // notification message
|
|
|
Title string `json:"title,omitempty"` // notification title
|
|
|
}
|
|
|
|
|
|
type UserStatus struct {
|
|
|
UserID string `json:"userID,omitempty"`
|
|
|
UserName string `json:"username,omitempty"`
|
|
|
IsAdmin bool `json:"isAdmin"`
|
|
|
PlayTime int64 `json:"playTime,omitempty"`
|
|
|
UpdateTime int64 `json:"updateTime,omitempty"`
|
|
|
Playing bool `json:"playing,omitempty"`
|
|
|
}
|
|
|
|
|
|
type DanmakuData struct {
|
|
|
ID string `json:"id,omitempty"` // 弹幕唯一标识符
|
|
|
SenderUID string `json:"senderID,omitempty"` // 发送者用户ID
|
|
|
SenderName string `json:"senderName,omitempty"` // 发送者用户名
|
|
|
Type int `json:"type,omitempty"` // 弹幕类型,1-滚动,2-顶部,3-底部
|
|
|
Color int `json:"color,omitempty"` // 弹幕颜色,对应16进制颜色值,如白色为0xFFFFFF
|
|
|
Text string `json:"text,omitempty"` // 弹幕内容
|
|
|
}
|
|
|
|
|
|
var MessageTypeRoomInfo = "roomInfo"
|
|
|
var MessageTypeJoined = "joined"
|
|
|
var MessageTypeUserJoin = "userJoin"
|
|
|
var MessageTypeUserLeave = "userLeave"
|
|
|
var MessageTypeMessage = "message"
|
|
|
var MessageTypePause = "pause"
|
|
|
var MessageTypePlay = "play"
|
|
|
var MessageTypeSetUrl = "setUrl"
|
|
|
var MessageTypeSetTime = "setTime"
|