Documentation
¶
Index ¶
- Constants
- func AddOnCloseListener(listener ...SessionListener)
- func AddOnCreateListener(listener ...SessionListener)
- func AddOnDataListener(listener ...SessionListener)
- func Bind(sid cfacade.SID, uid cfacade.UID) error
- func CloseAll(cb func(session *Session))
- func ForEachSIDSession(fn func(s *Session))
- func ForEachUIDSession(fn func(s *Session))
- func GetSessionCount() int
- func Kick(uid cfacade.UID) error
- func KickBySID(sid cfacade.SID) error
- func NextSID() cfacade.SID
- func Unbind(sid cfacade.SID)
- type Group
- func (c *Group) Add(session *Session) error
- func (c *Group) Broadcast(route string, v interface{}) error
- func (c *Group) Close() error
- func (c *Group) Contains(uid int64) bool
- func (c *Group) Count() int
- func (c *Group) Leave(s *Session) error
- func (c *Group) LeaveAll() error
- func (c *Group) Member(uid int64) (*Session, error)
- func (c *Group) Members() []int64
- func (c *Group) Multicast(route string, v interface{}, filter SessionFilter) error
- type Session
- func Create(sid cfacade.SID, frontendId cfacade.FrontendId, network cfacade.INetwork) *Session
- func FakeSession(request *cproto.Request, network cfacade.INetwork) *Session
- func GetBySID(sid cfacade.SID) (*Session, bool)
- func GetByUID(uid cfacade.UID) (*Session, bool)
- func NewSession(sid cfacade.SID, frontendId cfacade.FrontendId, network cfacade.INetwork) *Session
- func (s *Session) Clear()
- func (s *Session) Close()
- func (s *Session) Contains(key string) bool
- func (s *Session) Data() map[string]string
- func (s *Session) Debug(args ...interface{})
- func (s *Session) Debugf(template string, args ...interface{})
- func (s *Session) Error(args ...interface{})
- func (s *Session) Errorf(template string, args ...interface{})
- func (s *Session) FrontendId() cfacade.FrontendId
- func (s *Session) GetInt(key string) int
- func (s *Session) GetInt32(key string) int32
- func (s *Session) GetInt64(key string) int64
- func (s *Session) GetString(key string) string
- func (s *Session) ImportAll(settings map[string]string)
- func (s *Session) Info(args ...interface{})
- func (s *Session) Infof(template string, args ...interface{})
- func (s *Session) IsBind() bool
- func (s *Session) Kick(reason interface{}, close bool)
- func (s *Session) LogEnable(level zapcore.Level) bool
- func (s *Session) OnCloseListener()
- func (s *Session) OnDataListener() bool
- func (s *Session) Push(route string, v interface{})
- func (s *Session) RPC(nodeId string, route string, req proto.Message, rsp proto.Message) int32
- func (s *Session) RemoteAddress() string
- func (s *Session) Remove(key string)
- func (s *Session) Response(ctx context.Context, v interface{}, isError ...bool)
- func (s *Session) ResponseMID(mid uint, v interface{}, isError ...bool)
- func (s *Session) Restore(data map[string]string)
- func (s *Session) SID() cfacade.SID
- func (s *Session) SendRaw(bytes []byte)
- func (s *Session) Set(key string, value string)
- func (s *Session) SetState(state int32)
- func (s *Session) State() int32
- func (s *Session) String() string
- func (s *Session) UID() cfacade.UID
- func (s *Session) Warn(args ...interface{})
- func (s *Session) Warnf(template string, args ...interface{})
- type SessionFilter
- type SessionListener
Constants ¶
const ( Init = iota WaitAck Working Closed )
Variables ¶
This section is empty.
Functions ¶
func AddOnCloseListener ¶ added in v1.1.6
func AddOnCloseListener(listener ...SessionListener)
func AddOnCreateListener ¶ added in v1.1.6
func AddOnCreateListener(listener ...SessionListener)
func AddOnDataListener ¶ added in v1.1.24
func AddOnDataListener(listener ...SessionListener)
func ForEachSIDSession ¶ added in v1.1.6
func ForEachSIDSession(fn func(s *Session))
func ForEachUIDSession ¶ added in v1.1.6
func ForEachUIDSession(fn func(s *Session))
func GetSessionCount ¶ added in v1.1.6
func GetSessionCount() int
Types ¶
type Group ¶ added in v1.1.0
type Group struct {
// contains filtered or unexported fields
}
Group represents a session group which used to manage a number of sessions, data send to the group will send to all session in it.
func (*Group) Close ¶ added in v1.1.0
Close destroy group, which will release all resource in the group
func (*Group) Contains ¶ added in v1.1.0
Contains check whether a UID is contained in current group or not
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func FakeSession ¶ added in v1.1.20
func NewSession ¶
func (*Session) Clear ¶ added in v1.1.0
func (s *Session) Clear()
Clear releases all settings related to current sc
func (*Session) FrontendId ¶
func (s *Session) FrontendId() cfacade.FrontendId
func (*Session) GetInt32 ¶ added in v1.1.0
GetInt32 returns the value associated with the key as a int32.
func (*Session) GetInt64 ¶ added in v1.1.0
GetInt64 returns the value associated with the key as a int64.
func (*Session) GetString ¶ added in v1.1.0
GetString returns the value associated with the key as a string.
func (*Session) OnCloseListener ¶ added in v1.1.24
func (s *Session) OnCloseListener()
func (*Session) OnDataListener ¶ added in v1.1.24
func (*Session) RemoteAddress ¶ added in v1.1.0
func (*Session) ResponseMID ¶ added in v1.1.17
ResponseMID responses message to client, mid is request message ID
type SessionFilter ¶ added in v1.1.0
SessionFilter represents a filter which was used to filter session when Multicast, the session will receive the message while filter returns true.