Documentation ¶
Index ¶
- Constants
- Variables
- type Bucket
- func (b *Bucket) DelSession(uid string)
- func (b *Bucket) Enumerate(accept func(*Session))
- func (b *Bucket) FindRoom(rid string) *Room
- func (b *Bucket) FindSession(uid string) *Session
- func (b *Bucket) JoinRoom(uid, rid string) (orid string, err error)
- func (b *Bucket) Put(ses *Session) (*Session, error)
- func (b *Bucket) RoomsSnapshot() []*Room
- func (b *Bucket) SessionsSnapshot() []*Session
- type Room
- type Session
Constants ¶
View Source
const World = ""
World is the default room (identity) where a new session starts
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
Bucket is a shard of session holder
func (*Bucket) DelSession ¶
func (*Bucket) FindSession ¶
func (*Bucket) JoinRoom ¶
JoinRoom join the user's session (uid) to the room (rid), returns the original room (orid)
func (*Bucket) Put ¶
Put a session into the bucket, returns the last session. The bucket could be in an inconsistent state when error happens, to ensure a session is always removed from bucket when it is not needed, do as below:
_, err := bucket.Put(rmgr.NewSession(uid)) defer bucket.DelSession(uid) if err != nil { /* handle error and quit */ }
func (*Bucket) RoomsSnapshot ¶
func (*Bucket) SessionsSnapshot ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a user's session
func NewSession ¶
func NewSession(uid, rid string, cancel context.CancelFunc) *Session
Click to show internal directories.
Click to hide internal directories.