op

package
v0.6.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2024 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

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")
	ErrRoomCreatorBanned    = errors.New("room creator banned")
	ErrorRoomCreatorPending = errors.New("room creator pending, please wait for admin to approve")
)
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")
)
View Source
var ErrEmailUnbound = errors.New("email unbound")
View Source
var ErrNoCurrentMovie = errors.New("no current movie")

Functions

func CloseRoomById

func CloseRoomById(roomID string) error

func CloseUserById

func CloseUserById(id string) error

func CompareAndCloseRoom

func CompareAndCloseRoom(room *RoomEntry) bool

func CompareAndCloseUser

func CompareAndCloseUser(user *UserEntry) error

func CompareAndDeleteRoom

func CompareAndDeleteRoom(room *RoomEntry) error

func CompareAndDeleteUser

func CompareAndDeleteUser(user *UserEntry) error

func DeleteRoomByID

func DeleteRoomByID(roomID string) error

func DeleteUserByID

func DeleteUserByID(id string) error

func GetUserName

func GetUserName(userID string) string

func Init

func Init(size int) error

func PeopleNum added in v0.3.1

func PeopleNum(roomID string) int64

func RangeRoomCache added in v0.3.1

func RangeRoomCache(f func(key string, value *synccache.Entry[*Room]) bool)

func SetRoomStatusByID added in v0.3.2

func SetRoomStatusByID(roomID string, status model.RoomStatus) error

Types

type BroadcastConf

type BroadcastConf func(*broadcastMessage)

func WithIgnoreClient added in v0.3.1

func WithIgnoreClient(cli ...*Client) BroadcastConf

func WithIgnoreId

func WithIgnoreId(id ...string) BroadcastConf

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) Broadcast

func (c *Client) Broadcast(msg Message, conf ...BroadcastConf) error

func (*Client) Close

func (c *Client) Close() error

func (*Client) Closed

func (c *Client) Closed() bool

func (*Client) GetReadChan

func (c *Client) GetReadChan() <-chan Message

func (*Client) NextReader

func (c *Client) NextReader() (int, io.Reader, error)

func (*Client) NextWriter

func (c *Client) NextWriter(messageType int) (io.WriteCloser, error)

func (*Client) Room

func (c *Client) Room() *Room

func (*Client) Send

func (c *Client) Send(msg Message) error

func (*Client) SendChatMessage added in v0.5.0

func (c *Client) SendChatMessage(message string) error

func (*Client) SetSeekRate added in v0.5.0

func (c *Client) SetSeekRate(seek float64, rate float64, timeDiff float64) (*Status, error)

func (*Client) SetStatus added in v0.5.0

func (c *Client) SetStatus(playing bool, seek float64, rate float64, timeDiff float64) (*Status, error)

func (*Client) User

func (c *Client) User() *User

type Current

type Current struct {
	Movie  CurrentMovie
	Status Status
}

func (*Current) SetSeek

func (c *Current) SetSeek(seek, timeDiff float64) Status

func (*Current) SetSeekRate

func (c *Current) SetSeekRate(seek, rate, timeDiff float64) Status

func (*Current) SetStatus

func (c *Current) SetStatus(playing bool, seek, rate, timeDiff float64) Status

func (*Current) UpdateStatus added in v0.4.1

func (c *Current) UpdateStatus() Status

type CurrentMovie added in v0.6.0

type CurrentMovie struct {
	ID     string
	IsLive bool
}

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

func (*Hub) Broadcast

func (h *Hub) Broadcast(data Message, conf ...BroadcastConf) error

func (*Hub) Close

func (h *Hub) Close() error

func (*Hub) Closed

func (h *Hub) Closed() bool

func (*Hub) IsOnline added in v0.5.0

func (h *Hub) IsOnline(userID string) bool

func (*Hub) KickUser added in v0.5.0

func (h *Hub) KickUser(userID string) error

func (*Hub) OnlineCount added in v0.5.0

func (h *Hub) OnlineCount(userID string) int

func (*Hub) PeopleNum added in v0.3.1

func (h *Hub) PeopleNum() int64

func (*Hub) RegClient

func (h *Hub) RegClient(cli *Client) error

func (*Hub) SendToUser

func (h *Hub) SendToUser(userID string, data Message) (err error)

func (*Hub) Start

func (h *Hub) Start() error

func (*Hub) UnRegClient

func (h *Hub) UnRegClient(cli *Client) error

type Message

type Message interface {
	MessageType() int
	String() string
	Encode(w io.Writer) error
}

type Movie

type Movie struct {
	*model.Movie
	// contains filtered or unexported fields
}

func (*Movie) AlistCache added in v0.3.1

func (m *Movie) AlistCache() *cache.AlistMovieCache

func (*Movie) BilibiliCache added in v0.3.1

func (m *Movie) BilibiliCache() *cache.BilibiliMovieCache

func (*Movie) Channel

func (m *Movie) Channel() (*rtmps.Channel, error)

func (*Movie) CheckExpired added in v0.3.6

func (m *Movie) CheckExpired(expireId uint64) bool

func (*Movie) ClearCache added in v0.3.6

func (m *Movie) ClearCache() error

func (*Movie) Close added in v0.6.0

func (m *Movie) Close() error

func (*Movie) EmbyCache added in v0.3.1

func (m *Movie) EmbyCache() *cache.EmbyMovieCache

func (*Movie) ExpireId added in v0.3.6

func (m *Movie) ExpireId() uint64

func (*Movie) SubPath added in v0.6.0

func (m *Movie) SubPath() string

func (*Movie) Terminate

func (m *Movie) Terminate() error

func (*Movie) Validate

func (movie *Movie) Validate() error

type PingMessage

type PingMessage struct{}

func (*PingMessage) Encode

func (pm *PingMessage) Encode(w io.Writer) error

func (*PingMessage) MessageType

func (pm *PingMessage) MessageType() int

func (*PingMessage) String

func (pm *PingMessage) String() string

type Room

type Room struct {
	model.Room
	// contains filtered or unexported fields
}

func (*Room) AddAdminPermissions added in v0.5.0

func (r *Room) AddAdminPermissions(userID string, permissions model.RoomAdminPermission) error

func (*Room) AddMemberPermissions added in v0.5.0

func (r *Room) AddMemberPermissions(userID string, permissions model.RoomMemberPermission) error

func (*Room) AddMovie

func (r *Room) AddMovie(m *model.Movie) error

func (*Room) AddMovies

func (r *Room) AddMovies(movies []*model.Movie) error

func (*Room) ApprovePendingMember added in v0.5.0

func (r *Room) ApprovePendingMember(userID string) error

func (*Room) BanMember added in v0.5.0

func (r *Room) BanMember(userID string) error

func (*Room) Broadcast

func (r *Room) Broadcast(data Message, conf ...BroadcastConf) error

func (*Room) CheckCurrentExpired added in v0.3.6

func (r *Room) CheckCurrentExpired(expireId uint64) (bool, error)

func (*Room) CheckVersion

func (r *Room) CheckVersion(version uint32) bool

func (*Room) ClearMovies

func (r *Room) ClearMovies() error

func (*Room) ClearMoviesByParentID added in v0.6.0

func (r *Room) ClearMoviesByParentID(parentID string) error

func (*Room) Current

func (r *Room) Current() *Current

func (*Room) CurrentMovie added in v0.3.6

func (r *Room) CurrentMovie() CurrentMovie

func (*Room) DeleteMovieByID

func (r *Room) DeleteMovieByID(id string) error

func (*Room) DeleteMoviesByID added in v0.5.0

func (r *Room) DeleteMoviesByID(ids []string) error

func (*Room) GetChannel

func (r *Room) GetChannel(channelName string) (*rtmps.Channel, error)

func (*Room) GetMovieByID

func (r *Room) GetMovieByID(id string) (*Movie, error)

func (*Room) GetMoviesWithPage

func (r *Room) GetMoviesWithPage(page, pageSize int, parentID string) ([]*model.Movie, int64, error)

func (*Room) HasAdminPermission added in v0.5.0

func (r *Room) HasAdminPermission(userID string, permission model.RoomAdminPermission) bool

func (*Room) HasPermission

func (r *Room) HasPermission(userID string, permission model.RoomMemberPermission) bool

func (*Room) IsAdmin added in v0.5.0

func (r *Room) IsAdmin(userID string) bool

do not use this value for permission determination

func (*Room) IsCreator added in v0.5.0

func (r *Room) IsCreator(userID string) bool

func (*Room) IsGuest added in v0.5.0

func (r *Room) IsGuest(userID string) bool

func (*Room) IsParentOf added in v0.6.0

func (r *Room) IsParentOf(movieID, parentID string) (bool, error)

func (*Room) KickUser added in v0.5.0

func (r *Room) KickUser(userID string) error

func (*Room) LoadCurrentMovie added in v0.6.0

func (r *Room) LoadCurrentMovie() (*Movie, error)

func (*Room) LoadMemberStatus added in v0.5.0

func (r *Room) LoadMemberStatus(userID string) (model.RoomMemberStatus, error)

func (*Room) LoadOrCreateMemberStatus added in v0.5.0

func (r *Room) LoadOrCreateMemberStatus(userID string) (model.RoomMemberStatus, error)

func (*Room) LoadOrCreateRoomMember added in v0.5.0

func (r *Room) LoadOrCreateRoomMember(userID string) (*model.RoomMember, error)

func (*Room) LoadRoomAdminPermission added in v0.5.0

func (r *Room) LoadRoomAdminPermission(userID string) (model.RoomAdminPermission, error)

func (*Room) LoadRoomMember added in v0.5.0

func (r *Room) LoadRoomMember(userID string) (*model.RoomMember, error)

func (*Room) LoadRoomMemberPermission added in v0.5.0

func (r *Room) LoadRoomMemberPermission(userID string) (model.RoomMemberPermission, error)

func (*Room) NeedPassword

func (r *Room) NeedPassword() bool

func (*Room) NewClient added in v0.3.1

func (r *Room) NewClient(user *User, conn *websocket.Conn) (*Client, error)

func (*Room) PeopleNum added in v0.3.1

func (r *Room) PeopleNum() int64

func (*Room) RegClient

func (r *Room) RegClient(cli *Client) error

func (*Room) RemoveAdminPermissions added in v0.5.0

func (r *Room) RemoveAdminPermissions(userID string, permissions model.RoomAdminPermission) error

func (*Room) RemoveMemberPermissions added in v0.5.0

func (r *Room) RemoveMemberPermissions(userID string, permissions model.RoomMemberPermission) error

func (*Room) ResetAdminPermissions added in v0.5.0

func (r *Room) ResetAdminPermissions(userID string) error

func (*Room) ResetMemberPermissions added in v0.5.0

func (r *Room) ResetMemberPermissions(userID string) error

func (*Room) SendToUser

func (r *Room) SendToUser(user *User, data Message) error

func (*Room) SetAdmin added in v0.5.0

func (r *Room) SetAdmin(userID string, permissions model.RoomAdminPermission) error

func (*Room) SetAdminPermissions added in v0.5.0

func (r *Room) SetAdminPermissions(userID string, permissions model.RoomAdminPermission) error

func (*Room) SetCurrentMovie

func (r *Room) SetCurrentMovie(movieID string, subPath string, play bool) error

func (*Room) SetCurrentSeekRate added in v0.5.0

func (r *Room) SetCurrentSeekRate(seek float64, rate float64, timeDiff float64) *Status

func (*Room) SetCurrentStatus added in v0.5.0

func (r *Room) SetCurrentStatus(playing bool, seek float64, rate float64, timeDiff float64) *Status

func (*Room) SetMember added in v0.5.0

func (r *Room) SetMember(userID string, permissions model.RoomMemberPermission) error

func (*Room) SetMemberPermissions added in v0.5.0

func (r *Room) SetMemberPermissions(userID string, permissions model.RoomMemberPermission) error

func (*Room) SetPassword

func (r *Room) SetPassword(password string) error

func (*Room) SetSettings

func (r *Room) SetSettings(settings *model.RoomSettings) error

func (*Room) SwapMoviePositions

func (r *Room) SwapMoviePositions(id1, id2 string) error

func (*Room) UnbanMember added in v0.5.0

func (r *Room) UnbanMember(userID string) error

func (*Room) UnregisterClient

func (r *Room) UnregisterClient(cli *Client) error

func (*Room) UpdateMovie

func (r *Room) UpdateMovie(movieId string, movie *model.MovieBase) error

func (*Room) UpdateSettings added in v0.5.0

func (r *Room) UpdateSettings(settings map[string]any) error

func (*Room) UserIsOnline added in v0.5.0

func (r *Room) UserIsOnline(userID string) bool

func (*Room) UserOnlineCount added in v0.5.0

func (r *Room) UserOnlineCount(userID string) int

func (*Room) UserRole added in v0.5.0

func (r *Room) UserRole(userID string) (model.RoomMemberRole, error)

func (*Room) Version

func (r *Room) Version() uint32

type RoomEntry added in v0.3.2

type RoomEntry = synccache.Entry[*Room]

func CreateRoom

func CreateRoom(name, password string, maxCount int64, conf ...db.CreateRoomConfig) (*RoomEntry, error)

func LoadOrInitRoom

func LoadOrInitRoom(room *model.Room) (*RoomEntry, error)

func LoadOrInitRoomByID

func LoadOrInitRoomByID(id string) (*RoomEntry, error)

func LoadRoomByID

func LoadRoomByID(id string) (*RoomEntry, error)

type Status

type Status struct {
	Seek    float64 `json:"seek"`
	Rate    float64 `json:"rate"`
	Playing bool    `json:"playing"`
	// contains filtered or unexported fields
}

type User

type User struct {
	model.User
	// contains filtered or unexported fields
}

func (*User) AddMemberPermissions added in v0.5.0

func (u *User) AddMemberPermissions(room *Room, userID string, permissions model.RoomMemberPermission) error

func (*User) AddRoomAdminPermissions added in v0.5.0

func (u *User) AddRoomAdminPermissions(room *Room, userID string, permissions model.RoomAdminPermission) error

func (*User) AddRoomMovie added in v0.5.0

func (u *User) AddRoomMovie(room *Room, movie *model.MovieBase) (*model.Movie, error)

func (*User) AddRoomMovies added in v0.5.0

func (u *User) AddRoomMovies(room *Room, movies []*model.MovieBase) ([]*model.Movie, error)

func (*User) AlistCache added in v0.3.1

func (u *User) AlistCache() *cache.AlistUserCache

func (*User) ApproveRoomPendingMember added in v0.5.0

func (u *User) ApproveRoomPendingMember(room *Room, userID string) error

func (*User) Ban added in v0.5.0

func (u *User) Ban() error

func (*User) BanRoomMember added in v0.5.0

func (u *User) BanRoomMember(room *Room, userID string) error

func (*User) BilibiliCache added in v0.3.1

func (u *User) BilibiliCache() *cache.BilibiliUserCache

func (*User) BindEmail added in v0.4.5

func (u *User) BindEmail(e string) error

func (*User) BindProvider

func (u *User) BindProvider(p provider.OAuth2Provider, pid string) error

func (*User) CheckVersion

func (u *User) CheckVersion(version uint32) bool

func (*User) ClearRoomMovies added in v0.5.0

func (u *User) ClearRoomMovies(room *Room) error

func (*User) ClearRoomMoviesByParentID added in v0.6.0

func (u *User) ClearRoomMoviesByParentID(room *Room, parentID string) error

func (*User) CreateRoom

func (u *User) CreateRoom(name, password string, conf ...db.CreateRoomConfig) (*RoomEntry, error)

func (*User) DeleteRoom

func (u *User) DeleteRoom(room *RoomEntry) error

func (*User) DeleteRoomMovieByID added in v0.5.0

func (u *User) DeleteRoomMovieByID(room *Room, movieID string) error

func (*User) DeleteRoomMoviesByID added in v0.5.0

func (u *User) DeleteRoomMoviesByID(room *Room, movieIDs []string) error

func (*User) EmbyCache added in v0.3.1

func (u *User) EmbyCache() *cache.EmbyUserCache

func (*User) GetRoomMoviesWithPage added in v0.5.0

func (u *User) GetRoomMoviesWithPage(room *Room, page, pageSize int, parentID string) ([]*model.Movie, int64, error)

func (*User) HasRoomAdminPermission added in v0.5.0

func (u *User) HasRoomAdminPermission(room *Room, permission model.RoomAdminPermission) bool

func (*User) HasRoomPermission

func (u *User) HasRoomPermission(room *Room, permission model.RoomMemberPermission) bool

func (*User) IsAdmin

func (u *User) IsAdmin() bool

func (*User) IsBanned

func (u *User) IsBanned() bool

func (*User) IsGuest added in v0.5.0

func (u *User) IsGuest() bool

func (*User) IsPending

func (u *User) IsPending() bool

func (*User) IsRoomAdmin added in v0.5.0

func (u *User) IsRoomAdmin(room *Room) bool

func (*User) IsRoomCreator added in v0.5.0

func (u *User) IsRoomCreator(room *Room) bool

func (*User) IsRoot

func (u *User) IsRoot() bool

func (*User) NewMovie

func (u *User) NewMovie(movie *model.MovieBase) (*model.Movie, error)

func (*User) NewMovies

func (u *User) NewMovies(movies []*model.MovieBase) ([]*model.Movie, error)

func (*User) RemoveMemberPermissions added in v0.5.0

func (u *User) RemoveMemberPermissions(room *Room, userID string, permissions model.RoomMemberPermission) error

func (*User) RemoveRoomAdminPermissions added in v0.5.0

func (u *User) RemoveRoomAdminPermissions(room *Room, userID string, permissions model.RoomAdminPermission) error

func (*User) ResetMemberPermissions added in v0.5.0

func (u *User) ResetMemberPermissions(room *Room, userID string) error

func (*User) ResetRoomAdminPermissions added in v0.5.0

func (u *User) ResetRoomAdminPermissions(room *Room, userID string) error

func (*User) SendBindCaptchaEmail added in v0.4.5

func (u *User) SendBindCaptchaEmail(e string) error

func (*User) SendRetrievePasswordCaptchaEmail added in v0.4.5

func (u *User) SendRetrievePasswordCaptchaEmail(host string) error

func (*User) SendTestEmail added in v0.4.5

func (u *User) SendTestEmail() error

func (*User) SetAdminRole added in v0.5.0

func (u *User) SetAdminRole() error

func (*User) SetMemberPermissions added in v0.5.0

func (u *User) SetMemberPermissions(room *Room, userID string, permissions model.RoomMemberPermission) error

func (*User) SetPassword

func (u *User) SetPassword(password string) error

func (*User) SetRoomAdmin added in v0.5.0

func (u *User) SetRoomAdmin(room *Room, userID string, permissions model.RoomAdminPermission) error

func (*User) SetRoomAdminPermissions added in v0.5.0

func (u *User) SetRoomAdminPermissions(room *Room, userID string, permissions model.RoomAdminPermission) error

func (*User) SetRoomCurrentMovie added in v0.5.0

func (u *User) SetRoomCurrentMovie(room *Room, movieID string, subPath string, play bool) error

func (*User) SetRoomCurrentSeekRate added in v0.5.0

func (u *User) SetRoomCurrentSeekRate(room *Room, seek, rate, timeDiff float64) (*Status, error)

func (*User) SetRoomCurrentStatus added in v0.5.0

func (u *User) SetRoomCurrentStatus(room *Room, playing bool, seek, rate, timeDiff float64) (*Status, error)

func (*User) SetRoomMember added in v0.5.0

func (u *User) SetRoomMember(room *Room, userID string, permissions model.RoomMemberPermission) error

func (*User) SetRoomPassword

func (u *User) SetRoomPassword(room *Room, password string) error

func (*User) SetRoomSettings added in v0.5.0

func (u *User) SetRoomSettings(room *Room, setting *model.RoomSettings) error

func (*User) SetRootRole added in v0.5.0

func (u *User) SetRootRole() error

func (*User) SetUserRole added in v0.5.0

func (u *User) SetUserRole() error

func (*User) SetUsername

func (u *User) SetUsername(username string) error

func (*User) SwapRoomMoviePositions added in v0.5.0

func (u *User) SwapRoomMoviePositions(room *Room, id1, id2 string) error

func (*User) Unban added in v0.5.0

func (u *User) Unban() error

func (*User) UnbanRoomMember added in v0.5.0

func (u *User) UnbanRoomMember(room *Room, userID string) error

func (*User) UnbindEmail added in v0.4.5

func (u *User) UnbindEmail() error

func (*User) UpdateRoomMovie added in v0.5.0

func (u *User) UpdateRoomMovie(room *Room, movieID string, movie *model.MovieBase) error

func (*User) UpdateRoomSettings added in v0.5.0

func (u *User) UpdateRoomSettings(room *Room, settings map[string]interface{}) error

func (*User) VerifyBindCaptchaEmail added in v0.4.5

func (u *User) VerifyBindCaptchaEmail(e, captcha string) (bool, error)

func (*User) VerifyRetrievePasswordCaptchaEmail added in v0.4.5

func (u *User) VerifyRetrievePasswordCaptchaEmail(e, captcha string) (bool, error)

func (*User) Version

func (u *User) Version() uint32

type UserEntry added in v0.3.2

type UserEntry = synccache.Entry[*User]

func CreateOrLoadUser

func CreateOrLoadUser(username string, password string, conf ...db.CreateUserConfig) (*UserEntry, error)

func CreateOrLoadUserWithEmail added in v0.4.5

func CreateOrLoadUserWithEmail(username, password, email string, conf ...db.CreateUserConfig) (*UserEntry, error)

func CreateOrLoadUserWithProvider

func CreateOrLoadUserWithProvider(username, password string, p provider.OAuth2Provider, pid string, conf ...db.CreateUserConfig) (*UserEntry, error)

func CreateUser

func CreateUser(username string, password string, conf ...db.CreateUserConfig) (*UserEntry, error)

func CreateUserWithEmail added in v0.4.5

func CreateUserWithEmail(username, password, email string, conf ...db.CreateUserConfig) (*UserEntry, error)

func GetUserByProvider

func GetUserByProvider(p provider.OAuth2Provider, pid string) (*UserEntry, error)

func LoadOrInitUser

func LoadOrInitUser(u *model.User) (*UserEntry, error)

func LoadOrInitUserByEmail added in v0.4.5

func LoadOrInitUserByEmail(email string) (*UserEntry, error)

func LoadOrInitUserByID

func LoadOrInitUserByID(id string) (*UserEntry, error)

func LoadUserByUsername

func LoadUserByUsername(username string) (*UserEntry, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL