Documentation ¶
Index ¶
- Constants
- func Broadcast(msg interface{})
- func GetMsgBelongToControllerIdx(msgIndex int) int
- func GetMsgByIdx(msgIndex int) interface{}
- func GetMsgIdxByType(t reflect.Type) int
- func RecycleSession(ses Session)
- func RegisterMsg(msgIndex, controllerIndex int, msg interface{})
- func RegisterPeer(peer Peer)
- func RegisterSessionType(ses interface{})
- func SessionCount() int
- func SubmitMsgToAntsPool(c Controller, s Session, msg interface{})
- func UpdateSystemController(c Controller)
- type Controller
- type Options
- type Peer
- type PeerIdentify
- type PeerType
- type Ping
- type Pong
- type ProtoCol
- type Session
- type SessionAbility
- type SessionClose
- type SessionConnect
- type SessionController
- type SessionIdentify
- type SessionStore
- type SystemController
Constants ¶
View Source
const (
POOL_DEFAULT_SIZE = 1
)
View Source
const SYSTEM_CONTROLLER_IDX = 0
Variables ¶
This section is empty.
Functions ¶
func GetMsgByIdx ¶
func GetMsgByIdx(msgIndex int) interface{}
func GetMsgIdxByType ¶
func RecycleSession ¶ added in v1.0.5
func RecycleSession(ses 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 SubmitMsgToAntsPool ¶
func SubmitMsgToAntsPool(c Controller, s Session, msg interface{})
提交到协程池处理消息
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 Session ¶
type Session interface { //原始套接字 Socket() interface{} // 发送消息,消息需要以指针格式传入 Send(msg interface{}) // 断开 Close() // ID b ID() uint64 //数据存储 Value(obj ...interface{}) interface{} }
会话
func AddSession ¶ added in v1.0.5
func AddSession() Session
func FindSession ¶ added in v1.0.5
type SessionAbility ¶ added in v1.0.5
type SessionAbility interface { SetID(id uint64) JoinController(index int, c Controller) }
会话功能
type SessionClose ¶
type SessionClose struct { }
type SessionController ¶
type SessionController struct {
// contains filtered or unexported fields
}
消息路由
func (*SessionController) GetController ¶
func (s *SessionController) GetController(index int) (Controller, error)
func (*SessionController) JoinController ¶ added in v1.0.3
func (s *SessionController) JoinController(index int, c Controller)
type SessionIdentify ¶
type SessionIdentify struct {
// contains filtered or unexported fields
}
核心会话标志
func (*SessionIdentify) ID ¶
func (s *SessionIdentify) ID() uint64
func (*SessionIdentify) SetID ¶
func (s *SessionIdentify) SetID(id uint64)
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{})
Source Files ¶
Click to show internal directories.
Click to hide internal directories.