Documentation ¶
Index ¶
- func AfterInited(f func(*Session))
- func BeforeClosed(f func(*Session))
- func Closed(s *Session)
- func Inited(s *Session)
- func OnClosed(f func(*Session))
- func OnInited(f func(*Session))
- type EventCallback
- type KernelSession
- func (s *KernelSession) AddRemoteSessionAddr(addr string)
- func (s *KernelSession) Deserialize(data []byte, v interface{}) error
- func (s *KernelSession) NetworkEntity() NetworkEntity
- func (s *KernelSession) Push(route string, v interface{}) error
- func (s *KernelSession) RPC(mid uint64, route string, v interface{}) error
- func (s *KernelSession) RemoteSessionAddrs() []string
- func (s *KernelSession) Response(mid uint64, route string, v interface{}) error
- func (s *KernelSession) Router() *Router
- func (s *KernelSession) Serialize(v interface{}) ([]byte, error)
- type NetworkEntity
- type Router
- type Session
- func (s *Session) BindBranch(branch uint32)
- func (s *Session) BindShortVer(shortVer uint32)
- func (s *Session) BindUID(uid int64)
- func (s *Session) BindVersion(version string)
- func (s *Session) Bool(key string) bool
- func (s *Session) Branch() uint32
- 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() uint64
- 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) NID() uint64
- func (s *Session) On(ev string, f func(s *Session))
- func (s *Session) OnData(ev string, f func(s *Session, i ...interface{}))
- 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(route string, v interface{}) error
- func (s *Session) Restore(data map[string]interface{})
- func (s *Session) SID() uint64
- func (s *Session) Set(key string, value interface{})
- func (s *Session) ShortVer() uint32
- func (s *Session) State() map[string]interface{}
- func (s *Session) String(key string) string
- func (s *Session) Trigger(ev string, i ...interface{})
- 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{}
- func (s *Session) Version() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AfterInited ¶ added in v1.0.0
func AfterInited(f func(*Session))
AfterInited set a func that will be called after session inited
func BeforeClosed ¶ added in v1.0.0
func BeforeClosed(f func(*Session))
BeforeClosed set a func that will be called before session closed
func Closed ¶ added in v1.0.0
func Closed(s *Session)
Closed call all funcs that was registered by OnClosed
func Inited ¶ added in v1.0.0
func Inited(s *Session)
Inited call all funcs that was registered by OnInited
Types ¶
type EventCallback ¶ added in v1.0.0
type EventCallback func(*Session, ...interface{})
EventCallback is the func called after event trigged
type KernelSession ¶ added in v1.0.1
type KernelSession struct { sync.RWMutex // protect data VersionBound bool // session version bound MaxMid atomic.Uint64 DataType atomic.Uint32 // contains filtered or unexported fields }
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 NewKernelSession ¶ added in v1.0.1
func NewKernelSession(entity NetworkEntity, id uint64) *KernelSession
New returns a new session instance a NetworkEntity is a low-level network instance
func (*KernelSession) AddRemoteSessionAddr ¶ added in v1.1.1
func (s *KernelSession) AddRemoteSessionAddr(addr string)
func (*KernelSession) Deserialize ¶ added in v1.1.38
func (s *KernelSession) Deserialize(data []byte, v interface{}) error
func (*KernelSession) NetworkEntity ¶ added in v1.0.1
func (s *KernelSession) NetworkEntity() NetworkEntity
NetworkEntity returns the low-level network agent object
func (*KernelSession) Push ¶ added in v1.0.1
func (s *KernelSession) Push(route string, v interface{}) error
Push message to client
func (*KernelSession) RPC ¶ added in v1.0.1
func (s *KernelSession) RPC(mid uint64, route string, v interface{}) error
RPC sends message to remote server
func (*KernelSession) RemoteSessionAddrs ¶ added in v1.1.1
func (s *KernelSession) RemoteSessionAddrs() []string
func (*KernelSession) Response ¶ added in v1.0.1
func (s *KernelSession) Response(mid uint64, route string, v interface{}) error
Response message to client
func (*KernelSession) Router ¶ added in v1.0.1
func (s *KernelSession) Router() *Router
Router returns the service router
func (*KernelSession) Serialize ¶ added in v1.1.38
func (s *KernelSession) Serialize(v interface{}) ([]byte, error)
type NetworkEntity ¶
type NetworkEntity interface { Push(route string, v interface{}) error RPC(mid uint64, route string, v interface{}) error Response(mid uint64, route string, v interface{}) error Close() error RemoteAddr() net.Addr }
NetworkEntity represent low-level network instance
type Router ¶ added in v1.0.0
type Router struct {
// contains filtered or unexported fields
}
Router is used to select remote service address
type Session ¶
type Session struct { *KernelSession // contains filtered or unexported fields }
func New ¶
func New(entity NetworkEntity, id uint64) *Session
New returns a new session instance a NetworkEntity is a low-level network instance
func (*Session) BindBranch ¶ added in v1.0.1
func (*Session) BindShortVer ¶ added in v1.0.0
func (*Session) BindVersion ¶ added in v1.0.0
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) RemoteAddr ¶
RemoteAddr returns the remote network address.