Documentation ¶
Index ¶
- Variables
- type LifetimeHandler
- type NetworkEntity
- type Router
- type Session
- func (s *Session) Bind(uid int64) error
- func (s *Session) Clear()
- func (s *Session) Close()
- func (s *Session) Float32(key string) float32
- func (s *Session) Float64(key string) float64
- func (s *Session) HasKey(key string) bool
- func (s *Session) ID() int64
- func (s *Session) Int(key string) int
- func (s *Session) Int16(key string) int16
- func (s *Session) Int32(key string) int32
- func (s *Session) Int64(key string) int64
- func (s *Session) Int8(key string) int8
- func (s *Session) LastMid() uint64
- func (s *Session) NetworkEntity() NetworkEntity
- func (s *Session) Push(route string, v interface{}) error
- func (s *Session) RPC(route string, v interface{}) error
- func (s *Session) RemoteAddr() net.Addr
- func (s *Session) Remove(key string)
- func (s *Session) Response(v interface{}) error
- func (s *Session) ResponseMID(mid uint64, v interface{}) error
- func (s *Session) Restore(data map[string]interface{})
- func (s *Session) Router() *Router
- func (s *Session) Set(key string, value interface{})
- func (s *Session) State() map[string]interface{}
- func (s *Session) String(key string) string
- func (s *Session) UID() int64
- func (s *Session) Uint(key string) uint
- func (s *Session) Uint16(key string) uint16
- func (s *Session) Uint32(key string) uint32
- func (s *Session) Uint64(key string) uint64
- func (s *Session) Uint8(key string) uint8
- func (s *Session) Value(key string) interface{}
Constants ¶
This section is empty.
Variables ¶
var ( // ErrIllegalUID represents a invalid uid ErrIllegalUID = errors.New("illegal uid") )
var Lifetime = &lifetime{}
Functions ¶
This section is empty.
Types ¶
type LifetimeHandler ¶
type LifetimeHandler func(*Session)
LifetimeHandler represents a callback that will be called when a session close or session low-level connection broken.
type NetworkEntity ¶
type NetworkEntity interface { Push(route string, v interface{}) error RPC(route string, v interface{}) error LastMid() uint64 Response(v interface{}) error ResponseMid(mid uint64, v interface{}) error Close() error RemoteAddr() net.Addr }
NetworkEntity represent low-level network instance
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is used to select remote service address
type Session ¶
Session represents a client session which could storage temp data during low-level keep connected, all data will be released when the low-level connection was broken. Session instance related to the client will be passed to Handler method as the first parameter.
func New ¶
func New(entity NetworkEntity) *Session
New returns a new session instance a NetworkEntity is a low-level network instance
func (*Session) Clear ¶
func (s *Session) Clear()
Clear releases all data related to current session
func (*Session) Close ¶
func (s *Session) Close()
Close terminate current session, session related data will not be released, all related data should be Clear explicitly in Session closed callback
func (*Session) NetworkEntity ¶
func (s *Session) NetworkEntity() NetworkEntity
NetworkEntity returns the low-level network agent object
func (*Session) RemoteAddr ¶
RemoteAddr returns the remote network address.
func (*Session) ResponseMID ¶
ResponseMID responses message to client, mid is request message ID