Documentation
¶
Index ¶
- Variables
- func GetTheater(theaterId, token []byte) (*proto.Theater, error)
- func SendEventToUser(ctx context.Context, event []byte, user *proto.User)
- type Auth
- type Client
- func (c *Client) Close() error
- func (c *Client) GetUser() *proto.User
- func (c *Client) IsAuthenticated() bool
- func (c *Client) IsGuest() bool
- func (c *Client) Listen()
- func (c *Client) OnAuthorized(callback func(auth Auth) Room)
- func (c *Client) OnGuest(callback func(auth Auth) Room)
- func (c *Client) OnLeave(cb func(room Room))
- func (c *Client) OnUnauthorized(cb func())
- func (c *Client) PingPongHandler()
- func (c *Client) Token() []byte
- func (c *Client) WriteMessage(msg []byte) (err error)
- type ClientWithRoom
- type Hub
- type Room
- type RoomType
- type Session
- type TheaterHub
- type TheaterRoom
- func (room *TheaterRoom) GetName() string
- func (room *TheaterRoom) GetType() RoomType
- func (room *TheaterRoom) HandleEvents(client *Client) error
- func (room *TheaterRoom) Join(client *Client)
- func (room *TheaterRoom) Leave(client *Client)
- func (room *TheaterRoom) SendEventToTheaterMembers(ctx context.Context, event []byte)
- func (room *TheaterRoom) SubscribeEvents(client *Client)
- func (room *TheaterRoom) Sync(client *Client)
- type Timer
- type UserHub
- type UserRoom
- func (room *UserRoom) FeatchFriends(client *Client) ([]*proto.User, error)
- func (room *UserRoom) FeatchFriendsState(client *Client) error
- func (room *UserRoom) GetContext() context.Context
- func (room *UserRoom) GetName() string
- func (room *UserRoom) GetType() RoomType
- func (room *UserRoom) HandleEvents(client *Client) error
- func (room *UserRoom) Join(client *Client)
- func (room *UserRoom) Leave(client *Client)
- func (room *UserRoom) SubscribeEvents(client *Client)
- func (room *UserRoom) UpdateState(client *Client, state proto.PERSONAL_STATE)
- type VideoPlayer
- func (vp *VideoPlayer) CurrentTime() float32
- func (vp *VideoPlayer) CurrentTimeChan() <-chan float32
- func (vp *VideoPlayer) End()
- func (vp *VideoPlayer) InProgress() bool
- func (vp *VideoPlayer) Pause()
- func (vp *VideoPlayer) Play()
- func (vp *VideoPlayer) SetCurrentTime(currentTime float32)
- func (vp *VideoPlayer) Timer() *Timer
Constants ¶
This section is empty.
Variables ¶
View Source
var Subprotocols = []string{"cp0", "cp1"}
Functions ¶
Types ¶
type Client ¶
type Client struct { Id string Event chan *protocol.Packet // contains filtered or unexported fields }
func NewTheaterClient ¶
Create a new theater client
func NewUserClient ¶
Create a new user client
func (*Client) OnAuthorized ¶
Set a callback when client authorized
func (*Client) OnUnauthorized ¶
func (c *Client) OnUnauthorized(cb func())
Set a callback when client unauthorized
func (*Client) WriteMessage ¶
Write message to client
type ClientWithRoom ¶
type Session ¶
type Session struct { Id uint32 State *proto.PERSONAL_STATE StaticPersonalState bool // contains filtered or unexported fields }
func NewSession ¶
type TheaterHub ¶
type TheaterHub struct { VideoPlayers cmap.ConcurrentMap // contains filtered or unexported fields }
TheaterHub holds theater rooms
func (*TheaterHub) Close ¶
func (hub *TheaterHub) Close() error
func (*TheaterHub) ServeHTTP ¶
func (hub *TheaterHub) ServeHTTP(w http.ResponseWriter, req *http.Request)
Get ws conn. and hands it over to correct room
type TheaterRoom ¶
type TheaterRoom struct {
// contains filtered or unexported fields
}
func NewTheaterRoom ¶
func NewTheaterRoom(hub *TheaterHub, theater *proto.Theater) *TheaterRoom
create a new theater room
func (*TheaterRoom) GetName ¶
func (room *TheaterRoom) GetName() string
func (*TheaterRoom) GetType ¶
func (room *TheaterRoom) GetType() RoomType
func (*TheaterRoom) HandleEvents ¶
func (room *TheaterRoom) HandleEvents(client *Client) error
Handle client events
func (*TheaterRoom) SendEventToTheaterMembers ¶
func (room *TheaterRoom) SendEventToTheaterMembers(ctx context.Context, event []byte)
func (*TheaterRoom) SubscribeEvents ¶
func (room *TheaterRoom) SubscribeEvents(client *Client)
func (*TheaterRoom) Sync ¶
func (room *TheaterRoom) Sync(client *Client)
type UserHub ¶
type UserHub struct {
// contains filtered or unexported fields
}
Controls a bunch of rooms
type UserRoom ¶
type UserRoom struct {
// contains filtered or unexported fields
}
Has a name, clients, count which holds the actual coutn and index which acts as the unique id
func (*UserRoom) FeatchFriends ¶
func (*UserRoom) FeatchFriendsState ¶
func (*UserRoom) GetContext ¶
func (*UserRoom) HandleEvents ¶
Handle messages
func (*UserRoom) SubscribeEvents ¶
func (*UserRoom) UpdateState ¶
func (room *UserRoom) UpdateState(client *Client, state proto.PERSONAL_STATE)
type VideoPlayer ¶
func NewVideoPlayer ¶
func NewVideoPlayer() *VideoPlayer
func (*VideoPlayer) CurrentTime ¶
func (vp *VideoPlayer) CurrentTime() float32
func (*VideoPlayer) CurrentTimeChan ¶
func (vp *VideoPlayer) CurrentTimeChan() <-chan float32
func (*VideoPlayer) End ¶
func (vp *VideoPlayer) End()
func (*VideoPlayer) InProgress ¶
func (vp *VideoPlayer) InProgress() bool
func (*VideoPlayer) Pause ¶
func (vp *VideoPlayer) Pause()
func (*VideoPlayer) Play ¶
func (vp *VideoPlayer) Play()
func (*VideoPlayer) SetCurrentTime ¶
func (vp *VideoPlayer) SetCurrentTime(currentTime float32)
func (*VideoPlayer) Timer ¶
func (vp *VideoPlayer) Timer() *Timer
Click to show internal directories.
Click to hide internal directories.