You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.6 KiB
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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"