Documentation ¶
Index ¶
- Variables
- func ClientNum(roomID string) int64
- func CloseRoomById(roomID string) error
- func CloseUserById(id string) error
- func CompareAndCloseRoom(room *Room) error
- func CompareAndCloseRoomEntry(id string, room *synccache.Entry[*Room]) error
- func CompareAndCloseUser(user *User) error
- func CompareAndDeleteRoom(room *Room) error
- func CompareAndDeleteUser(user *User) error
- func DeleteRoomByID(roomID string) error
- func DeleteUserByID(id string) error
- func GetUserName(userID string) string
- func HasRoom(roomID string) bool
- func HasRoomByName(name string) bool
- func Init(size int) error
- func SetRoleByID(userID string, role model.Role) error
- func SetRoomStatus(roomID string, status model.RoomStatus) error
- type BaseCache
- func (b *BaseCache) Clear()
- func (b *BaseCache) InitOrLoadMPDCache(id string, refreshFunc func() (*MPDCache, error), maxAge time.Duration) (*refreshcache.RefreshCache[*MPDCache], error)
- func (b *BaseCache) InitOrLoadURLCache(id string, refreshFunc func() (string, error), maxAge time.Duration) (*refreshcache.RefreshCache[string], error)
- type BroadcastConf
- type Client
- func (c *Client) Broadcast(msg Message, conf ...BroadcastConf) error
- func (c *Client) Close() error
- func (c *Client) Closed() bool
- func (c *Client) GetReadChan() <-chan Message
- func (c *Client) NextReader() (int, io.Reader, error)
- func (c *Client) NextWriter(messageType int) (io.WriteCloser, error)
- func (c *Client) Room() *Room
- func (c *Client) Send(msg Message) error
- func (c *Client) User() *User
- type Current
- type ElementJsonMessage
- type ElementMessage
- type Hub
- func (h *Hub) Broadcast(data Message, conf ...BroadcastConf) error
- func (h *Hub) ClientNum() int64
- func (h *Hub) Close() error
- func (h *Hub) Closed() bool
- func (h *Hub) RegClient(cli *Client) (*Client, error)
- func (h *Hub) SendToUser(userID string, data Message) error
- func (h *Hub) Start() error
- func (h *Hub) UnRegClient(user *User) error
- type MPDCache
- type Message
- type Movie
- type PingMessage
- type Room
- func CreateRoom(name, password string, maxCount int64, conf ...db.CreateRoomConfig) (*Room, error)
- func GetAllRoomsInCacheWithNoNeedPassword() []*Room
- func GetAllRoomsInCacheWithoutHidden() []*Room
- func LoadOrInitRoom(room *model.Room) (*Room, error)
- func LoadOrInitRoomByID(id string) (*Room, error)
- func LoadRoomByID(id string) (*Room, error)
- func (r *Room) AddMovie(m *model.Movie) error
- func (r *Room) AddMovies(movies []*model.Movie) error
- func (r *Room) AddUserPermission(userID string, permission model.RoomUserPermission) error
- func (r *Room) Broadcast(data Message, conf ...BroadcastConf) error
- func (r *Room) CheckVersion(version uint32) bool
- func (r *Room) ClearMovies() error
- func (r *Room) ClientNum() int64
- func (r *Room) Current() *Current
- func (r *Room) DeleteMovieByID(id string) error
- func (r *Room) GetChannel(channelName string) (*rtmps.Channel, error)
- func (r *Room) GetMovieByID(id string) (*Movie, error)
- func (r *Room) GetMoviesCount() int
- func (r *Room) GetMoviesWithPage(page, pageSize int) []*Movie
- func (r *Room) GetRoomUserRelation(userID string) (model.RoomUserPermission, error)
- func (r *Room) HasPermission(userID string, permission model.RoomUserPermission) bool
- func (r *Room) LoadOrCreateRoomUserRelation(userID string) (*model.RoomUserRelation, error)
- func (r *Room) NeedPassword() bool
- func (r *Room) RegClient(user *User, conn *websocket.Conn) (*Client, error)
- func (r *Room) RemoveUserPermission(userID string, permission model.RoomUserPermission) error
- func (r *Room) SendToUser(user *User, data Message) error
- func (r *Room) SetCurrentMovie(movie *Movie, play bool)
- func (r *Room) SetCurrentMovieByID(id string, play bool) error
- func (r *Room) SetPassword(password string) error
- func (r *Room) SetRoomStatus(status model.RoomStatus) error
- func (r *Room) SetSeekRate(seek float64, rate float64, timeDiff float64) Status
- func (r *Room) SetSettings(settings model.RoomSettings) error
- func (r *Room) SetStatus(playing bool, seek float64, rate float64, timeDiff float64) Status
- func (r *Room) SetUserPermission(userID string, permission model.RoomUserPermission) error
- func (r *Room) SetUserStatus(userID string, status model.RoomUserStatus) error
- func (r *Room) SwapMoviePositions(id1, id2 string) error
- func (r *Room) UnregisterClient(user *User) error
- func (r *Room) UpdateMovie(movieId string, movie *model.BaseMovie) error
- func (r *Room) Version() uint32
- type RoomInfo
- type Status
- type User
- func CreateOrLoadUser(username string, password string, conf ...db.CreateUserConfig) (*User, error)
- func CreateOrLoadUserWithProvider(username, password string, p provider.OAuth2Provider, pid string, ...) (*User, error)
- func CreateUser(username string, password string, conf ...db.CreateUserConfig) (*User, error)
- func GetUserByProvider(p provider.OAuth2Provider, pid string) (*User, error)
- func LoadOrInitUser(u *model.User) (*User, error)
- func LoadOrInitUserByID(id string) (*User, error)
- func LoadUserByUsername(username string) (*User, error)
- func (u *User) AddMovieToRoom(room *Room, movie *model.BaseMovie) error
- func (u *User) AddMoviesToRoom(room *Room, movies []*model.BaseMovie) error
- func (u *User) BindProvider(p provider.OAuth2Provider, pid string) error
- func (u *User) CheckVersion(version uint32) bool
- func (u *User) ClearMovies(room *Room) error
- func (u *User) CreateRoom(name, password string, conf ...db.CreateRoomConfig) (*Room, error)
- func (u *User) DeleteMovieByID(room *Room, movieID string) error
- func (u *User) DeleteMoviesByID(room *Room, movieIDs []string) error
- func (u *User) DeleteRoom(room *Room) error
- func (u *User) HasRoomPermission(room *Room, permission model.RoomUserPermission) bool
- func (u *User) IsAdmin() bool
- func (u *User) IsBanned() bool
- func (u *User) IsPending() bool
- func (u *User) IsRoot() bool
- func (u *User) NewMovie(movie *model.BaseMovie) *model.Movie
- func (u *User) NewMovies(movies []*model.BaseMovie) []*model.Movie
- func (u *User) SetCurrentMovie(room *Room, movie *Movie, play bool) error
- func (u *User) SetCurrentMovieByID(room *Room, movieID string, play bool) error
- func (u *User) SetPassword(password string) error
- func (u *User) SetRole(role model.Role) error
- func (u *User) SetRoomPassword(room *Room, password string) error
- func (u *User) SetRoomSetting(room *Room, setting model.RoomSettings) error
- func (u *User) SetUsername(username string) error
- func (u *User) UpdateMovie(room *Room, movieID string, movie *model.BaseMovie) error
- func (u *User) Version() uint32
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrRoomPending = errors.New("room pending, please wait for admin to approve") ErrRoomBanned = errors.New("room banned") )
View Source
var ( ErrUserBanned = errors.New("user banned") ErrUserPending = errors.New("user pending, please wait for admin to approve") )
View Source
var (
ErrAlreadyClosed = fmt.Errorf("already closed")
)
Functions ¶
func CloseRoomById ¶
func CloseUserById ¶
func CompareAndCloseRoom ¶
func CompareAndCloseUser ¶
func CompareAndDeleteRoom ¶
func CompareAndDeleteUser ¶
func DeleteRoomByID ¶
func DeleteUserByID ¶
func GetUserName ¶
func HasRoomByName ¶
func SetRoomStatus ¶
func SetRoomStatus(roomID string, status model.RoomStatus) error
Types ¶
type BaseCache ¶
type BaseCache struct {
// contains filtered or unexported fields
}
func (*BaseCache) InitOrLoadMPDCache ¶
func (b *BaseCache) InitOrLoadMPDCache(id string, refreshFunc func() (*MPDCache, error), maxAge time.Duration) (*refreshcache.RefreshCache[*MPDCache], error)
func (*BaseCache) InitOrLoadURLCache ¶
func (b *BaseCache) InitOrLoadURLCache(id string, refreshFunc func() (string, error), maxAge time.Duration) (*refreshcache.RefreshCache[string], error)
type BroadcastConf ¶
type BroadcastConf func(*broadcastMessage)
func WithIgnoreId ¶
func WithIgnoreId(id ...string) BroadcastConf
func WithSendToSelf ¶
func WithSendToSelf() BroadcastConf
func WithSender ¶
func WithSender(sender string) BroadcastConf
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetReadChan ¶
func (*Client) NextWriter ¶
func (c *Client) NextWriter(messageType int) (io.WriteCloser, error)
type Current ¶
func (*Current) SetSeekRate ¶
func (*Current) UpdateSeek ¶
func (c *Current) UpdateSeek()
type ElementJsonMessage ¶
type ElementJsonMessage struct { BeforeSendFunc func(sendTo *User) error *pb.ElementMessage }
func (*ElementJsonMessage) BeforeSend ¶
func (em *ElementJsonMessage) BeforeSend(sendTo *User) error
func (*ElementJsonMessage) MessageType ¶
func (em *ElementJsonMessage) MessageType() int
func (*ElementJsonMessage) String ¶
func (em *ElementJsonMessage) String() string
type ElementMessage ¶
type ElementMessage struct { BeforeSendFunc func(sendTo *User) error *pb.ElementMessage }
func (*ElementMessage) BeforeSend ¶
func (em *ElementMessage) BeforeSend(sendTo *User) error
func (*ElementMessage) MessageType ¶
func (em *ElementMessage) MessageType() int
func (*ElementMessage) String ¶
func (em *ElementMessage) String() string
type PingMessage ¶
type PingMessage struct{}
func (*PingMessage) BeforeSend ¶
func (pm *PingMessage) BeforeSend(sendTo *User) error
func (*PingMessage) MessageType ¶
func (pm *PingMessage) MessageType() int
func (*PingMessage) String ¶
func (pm *PingMessage) String() string
type Room ¶
func CreateRoom ¶
func GetAllRoomsInCacheWithNoNeedPassword ¶
func GetAllRoomsInCacheWithNoNeedPassword() []*Room
func GetAllRoomsInCacheWithoutHidden ¶
func GetAllRoomsInCacheWithoutHidden() []*Room
func LoadOrInitRoomByID ¶
func LoadRoomByID ¶
func (*Room) AddUserPermission ¶
func (r *Room) AddUserPermission(userID string, permission model.RoomUserPermission) error
func (*Room) CheckVersion ¶
func (*Room) ClearMovies ¶
func (*Room) DeleteMovieByID ¶
func (*Room) GetMoviesCount ¶
func (*Room) GetMoviesWithPage ¶
func (*Room) GetRoomUserRelation ¶
func (r *Room) GetRoomUserRelation(userID string) (model.RoomUserPermission, error)
func (*Room) HasPermission ¶
func (r *Room) HasPermission(userID string, permission model.RoomUserPermission) bool
func (*Room) LoadOrCreateRoomUserRelation ¶
func (r *Room) LoadOrCreateRoomUserRelation(userID string) (*model.RoomUserRelation, error)
func (*Room) NeedPassword ¶
func (*Room) RemoveUserPermission ¶
func (r *Room) RemoveUserPermission(userID string, permission model.RoomUserPermission) error
func (*Room) SetCurrentMovie ¶
func (*Room) SetPassword ¶
func (*Room) SetRoomStatus ¶
func (r *Room) SetRoomStatus(status model.RoomStatus) error
func (*Room) SetSeekRate ¶
func (*Room) SetSettings ¶
func (r *Room) SetSettings(settings model.RoomSettings) error
func (*Room) SetUserPermission ¶
func (r *Room) SetUserPermission(userID string, permission model.RoomUserPermission) error
func (*Room) SetUserStatus ¶
func (r *Room) SetUserStatus(userID string, status model.RoomUserStatus) error
func (*Room) SwapMoviePositions ¶
func (*Room) UnregisterClient ¶
type RoomInfo ¶
type RoomInfo struct { RoomId string `json:"roomId"` RoomName string `json:"roomName"` PeopleNum int64 `json:"peopleNum"` NeedPassword bool `json:"needPassword"` CreatorID string `json:"creatorId"` Creator string `json:"creator"` CreatedAt int64 `json:"createdAt"` Status model.RoomStatus `json:"status"` }
func GetRoomHeapInCacheWithoutHidden ¶
func GetRoomHeapInCacheWithoutHidden() []*RoomInfo
type User ¶
func CreateOrLoadUser ¶
func CreateOrLoadUserWithProvider ¶
func CreateOrLoadUserWithProvider(username, password string, p provider.OAuth2Provider, pid string, conf ...db.CreateUserConfig) (*User, error)
func CreateUser ¶
func GetUserByProvider ¶
func GetUserByProvider(p provider.OAuth2Provider, pid string) (*User, error)
func LoadOrInitUserByID ¶
func LoadUserByUsername ¶
func (*User) AddMovieToRoom ¶
func (*User) AddMoviesToRoom ¶
func (*User) BindProvider ¶
func (u *User) BindProvider(p provider.OAuth2Provider, pid string) error
func (*User) CheckVersion ¶
func (*User) ClearMovies ¶
func (*User) CreateRoom ¶
func (*User) DeleteMoviesByID ¶
func (*User) DeleteRoom ¶
func (*User) HasRoomPermission ¶
func (u *User) HasRoomPermission(room *Room, permission model.RoomUserPermission) bool
func (*User) SetCurrentMovie ¶
func (*User) SetCurrentMovieByID ¶
func (*User) SetPassword ¶
func (*User) SetRoomSetting ¶
func (u *User) SetRoomSetting(room *Room, setting model.RoomSettings) error
func (*User) SetUsername ¶
func (*User) UpdateMovie ¶
Click to show internal directories.
Click to hide internal directories.