op

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: AGPL-3.0 Imports: 31 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")
)

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) User

func (c *Client) User() *User

type Current

type Current struct {
	Movie  model.Movie `json:"movie"`
	Status Status      `json:"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) UpdateSeek

func (c *Current) UpdateSeek()

type ElementMessage

type ElementMessage pb.ElementMessage

func (*ElementMessage) Encode

func (em *ElementMessage) Encode(w io.Writer) error

func (*ElementMessage) MessageType

func (em *ElementMessage) MessageType() int

func (*ElementMessage) String

func (em *ElementMessage) String() string

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) 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 {
	Movie 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) EmbyCache added in v0.3.1

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

func (*Movie) Terminate

func (m *Movie) Terminate() error

func (*Movie) Update

func (m *Movie) Update(movie *model.BaseMovie) 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) AddMovie

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

func (*Room) AddMovies

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

func (*Room) AddUserPermission

func (r *Room) AddUserPermission(userID string, permission model.RoomUserPermission) error

func (*Room) Broadcast

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

func (*Room) CheckVersion

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

func (*Room) ClearMovies

func (r *Room) ClearMovies() error

func (*Room) Current

func (r *Room) Current() *Current

func (*Room) DeleteMovieByID

func (r *Room) DeleteMovieByID(id 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) GetMoviesCount

func (r *Room) GetMoviesCount() int

func (*Room) GetMoviesWithPage

func (r *Room) GetMoviesWithPage(page, pageSize int) []*Movie

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 (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) RemoveUserPermission

func (r *Room) RemoveUserPermission(userID string, permission model.RoomUserPermission) error

func (*Room) SendToUser

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

func (*Room) SetCurrentMovie

func (r *Room) SetCurrentMovie(movie *model.Movie, play bool)

func (*Room) SetCurrentMovieByID

func (r *Room) SetCurrentMovieByID(id string, play bool) error

func (*Room) SetPassword

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

func (*Room) SetRoomStatus

func (r *Room) SetRoomStatus(status model.RoomStatus) error

func (*Room) SetSeekRate

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

func (*Room) SetSettings

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

func (*Room) SetStatus

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

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 (r *Room) SwapMoviePositions(id1, id2 string) error

func (*Room) UnregisterClient

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

func (*Room) UpdateMovie

func (r *Room) UpdateMovie(movieId string, movie *model.BaseMovie) 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) AddMovieToRoom

func (u *User) AddMovieToRoom(room *Room, movie *model.BaseMovie) error

func (*User) AddMoviesToRoom

func (u *User) AddMoviesToRoom(room *Room, movies []*model.BaseMovie) error

func (*User) AlistCache added in v0.3.1

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

func (*User) BilibiliCache added in v0.3.1

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

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) ClearMovies

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

func (*User) CreateRoom

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

func (*User) DeleteMovieByID

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

func (*User) DeleteMoviesByID

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

func (*User) DeleteRoom

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

func (*User) EmbyCache added in v0.3.1

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

func (*User) HasRoomPermission

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

func (*User) IsAdmin

func (u *User) IsAdmin() bool

func (*User) IsBanned

func (u *User) IsBanned() bool

func (*User) IsPending

func (u *User) IsPending() bool

func (*User) IsRoot

func (u *User) IsRoot() bool

func (*User) NewMovie

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

func (*User) NewMovies

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

func (*User) SetCurrentMovie

func (u *User) SetCurrentMovie(room *Room, movie *model.Movie, play bool) error

func (*User) SetCurrentMovieByID

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

func (*User) SetPassword

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

func (*User) SetRole

func (u *User) SetRole(role model.Role) error

func (*User) SetRoomPassword

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

func (*User) SetRoomSetting

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

func (*User) SetUsername

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

func (*User) UpdateMovie

func (u *User) UpdateMovie(room *Room, movieID string, movie *model.BaseMovie) 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 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 GetUserByProvider

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

func LoadOrInitUser

func LoadOrInitUser(u *model.User) (*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