Documentation ¶
Index ¶
- Constants
- func Broadcast(msg interface{})
- func FindMsg(msgID int) interface{}
- func FindMsgIDByType(t reflect.Type) int
- func GetMsgBelongToControllerIdx(msgIndex int) int
- func HandleEvent(e Event)
- func NewSessionManager() *sessionManager
- func RecycleSession(s Session)
- func RegisterMsg(msgID, controllerIndex int, msg interface{})
- func RegisterPeer(peer Peer)
- func RegisterSessionType(ses interface{})
- func SessionCount() int
- func TuneHandlerCount(count int)
- func UpdateSysRoute(c Route)
- type Event
- type Options
- type Peer
- type PeerIdentify
- type PeerType
- type Ping
- type Pong
- type ProtoCol
- type Route
- type Session
- type SessionClose
- type SessionConnect
- type SessionIdentify
- type SessionRoute
- type SessionStore
- type SystemController
Constants ¶
View Source
const (
Default_Handler_Count = 10
)
View Source
const System_Route_ID = 0
Variables ¶
This section is empty.
Functions ¶
func FindMsgIDByType ¶ added in v1.0.7
func NewSessionManager ¶ added in v1.1.0
func NewSessionManager() *sessionManager
func RecycleSession ¶ added in v1.0.5
func RecycleSession(s Session)
func RegisterPeer ¶
func RegisterPeer(peer Peer)
func RegisterSessionType ¶ added in v1.0.3
func RegisterSessionType(ses interface{})
func SessionCount ¶ added in v1.0.5
func SessionCount() int
func UpdateSysRoute ¶ added in v1.1.0
func UpdateSysRoute(c Route)
Types ¶
type Options ¶
type Options struct { //listen or dial addr Addr string //peer type PeerType PeerType //SetWriteDeadline sets the write deadline or read deadline on the underlying connection. ReadDeadline, WriteDeadline time.Duration //set the routine pool size //0.mean use default set PoolSize int // PanicHandler is used to handle panics from each worker goroutine. PanicHandler func(interface{}) //Maximum number of connections allowed //0.mean no limit AllowMaxConn int }
options
type PeerIdentify ¶
type PeerIdentify struct {
// contains filtered or unexported fields
}
端属性
func (*PeerIdentify) Addr ¶
func (p *PeerIdentify) Addr() string
func (*PeerIdentify) Options ¶ added in v1.0.3
func (p *PeerIdentify) Options(o Options)
func (*PeerIdentify) SetAddr ¶
func (p *PeerIdentify) SetAddr(addr string)
func (*PeerIdentify) SetOptions ¶ added in v1.0.3
func (p *PeerIdentify) SetOptions(o Options)
func (*PeerIdentify) SetType ¶
func (p *PeerIdentify) SetType(t PeerType)
func (*PeerIdentify) Type ¶
func (p *PeerIdentify) Type() PeerType
type Route ¶ added in v1.1.0
type Route interface {
OnMsg(session Session, msg interface{})
}
消息路由接口
type Session ¶
type Session interface { //原始套接字 Socket() interface{} // 发送消息,消息需要以指针格式传入 Send(msg interface{}) // 断开 Close() // ID b ID() uint64 //数据存储 Value(obj ...interface{}) interface{} //加入或者更新路由 JoinOrUpdateRoute(index int, c Route) }
会话
func AddSession ¶ added in v1.0.5
func AddSession() Session
func FindSession ¶ added in v1.0.5
type SessionClose ¶
type SessionClose struct { }
type SessionIdentify ¶
type SessionIdentify struct {
// contains filtered or unexported fields
}
核心会话标志
func (*SessionIdentify) ID ¶
func (s *SessionIdentify) ID() uint64
type SessionRoute ¶ added in v1.1.0
type SessionRoute struct {
// contains filtered or unexported fields
}
消息路由
func (*SessionRoute) GetRoute ¶ added in v1.1.3
func (s *SessionRoute) GetRoute(index int) (Route, error)
func (*SessionRoute) JoinOrUpdateRoute ¶ added in v1.1.3
func (s *SessionRoute) JoinOrUpdateRoute(index int, c Route)
type SessionStore ¶ added in v1.0.3
type SessionStore struct {
// contains filtered or unexported fields
}
存储功能
func (*SessionStore) Value ¶ added in v1.0.3
func (s *SessionStore) Value(v ...interface{}) interface{}
type SystemController ¶
type SystemController struct { }
系统控制模块
func (*SystemController) OnMsg ¶
func (*SystemController) OnMsg(session Session, msg interface{})
Click to show internal directories.
Click to hide internal directories.