Documentation
¶
Index ¶
- Variables
- func BroadcastMessage(users []string, send interface{}, filter *SessionFilter, exclude ...string)
- func GetSessionByUID(uid string, filter *SessionFilter) ([]int64, []int64)
- func NewSessionPool(config *config.Config) *sessionPoolImpl
- func SendMessageByID(sessionId int64, in interface{})
- type Session
- func (sess *Session) Close()
- func (sess *Session) GetConnInfo() *acceptor.ConnInfo
- func (sess *Session) GetData() SessionData
- func (sess *Session) GetLastTimeOnline() int64
- func (sess *Session) GetLatency() int64
- func (sess *Session) GetOnCloseCallbacks() []func(id int64)
- func (sess *Session) ID() int64
- func (sess *Session) IsLogin() bool
- func (sess *Session) OnClose(c func(id int64)) error
- func (sess *Session) SendData(data []byte)
- func (sess *Session) SendMessage(in interface{}, name ...string) error
- func (sess *Session) SetOnCloseCallback(c func(id int64))
- func (sess *Session) SetOnCloseCallbacks(callbacks []func(id int64))
- func (sess *Session) SetUID(uid string)
- func (sess *Session) UID() string
- type SessionData
- type SessionFilter
- type SessionMemeory
- type SessionPool
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrSessionNotFound = errors.New("session not found")
)
Functions ¶
func BroadcastMessage ¶ added in v0.1.1
func BroadcastMessage(users []string, send interface{}, filter *SessionFilter, exclude ...string)
BroadcastMessage broadcast message to all sessions except the session with the given id. the filter is used to filter the sessions that should not receive the message.
func GetSessionByUID ¶
func GetSessionByUID(uid string, filter *SessionFilter) ([]int64, []int64)
GetSessionByUID get session by user id. the filter is used to filter the sessions that should not receive the message.
func NewSessionPool ¶
func SendMessageByID ¶ added in v0.1.1
func SendMessageByID(sessionId int64, in interface{})
SendMessageByID send message to the session with the given id.
Types ¶
type Session ¶
type Session struct {
OnCloseCallbacks []func(id int64) // close callback
// contains filtered or unexported fields
}
func GetSessionByID ¶
func ListSessions ¶
func ListSessions() []*Session
func (*Session) GetConnInfo ¶
func (*Session) GetData ¶
func (sess *Session) GetData() SessionData
func (*Session) GetLastTimeOnline ¶
func (*Session) GetLatency ¶
func (*Session) GetOnCloseCallbacks ¶
func (*Session) SendMessage ¶
func (*Session) SetOnCloseCallback ¶ added in v0.1.5
func (*Session) SetOnCloseCallbacks ¶
type SessionData ¶
type SessionFilter ¶
SessionFilter can filter the session from session list one user maybe has many session, so we can filter the session
type SessionMemeory ¶
func NewSessionMemeory ¶
func NewSessionMemeory() *SessionMemeory
func (*SessionMemeory) Delete ¶
func (sess *SessionMemeory) Delete(key string)
func (*SessionMemeory) Get ¶
func (sess *SessionMemeory) Get(key string) (interface{}, bool)
func (*SessionMemeory) GetData ¶
func (sess *SessionMemeory) GetData() map[string]interface{}
GetData gets the data
func (*SessionMemeory) GetString ¶
func (sess *SessionMemeory) GetString(key, def string) string
func (*SessionMemeory) Set ¶
func (sess *SessionMemeory) Set(key string, value interface{})
Set associates value with the key in session storage
type SessionPool ¶
type SessionPool interface {
CreateSession(agent networkentity.NetworkEntity) *Session // create session
DeleteSession(id int64) // delete session by id
GetSessionCount() int64 // get current session count
GetSessionTotalCount() int64 // get total session count
GetSessionByID(int64) (*Session, error) // get session by id
GetSessionByUID(string, *SessionFilter) ([]int64, []int64) // get session by uid with filter
ListSessions() []*Session // list all session
CloseAll() // close all session
}
var DefaultSessionPool SessionPool
Click to show internal directories.
Click to hide internal directories.