监听器定义
type SessionLearner interface {
Connect(a Session)
DisConnect(a Session)
}
实现示例
func (this *Gate) Connect(session gate.Session) {
agent,err:=this.GetGateHandler().GetAgent(session.GetSessionId())
if err!=nil{
}
agent.ConnTime()
}
func (this *Gate) DisConnect(session gate.Session) {
}
设置监听器
func (this *Gate) OnInit(app module.App, settings *conf.ModuleSettings) {
this.Gate.OnInit(this, app, settings,
gate.SetSessionLearner(this),
)
}
获取连接代理对象(agent)
agent,err:=this.GetGateHandler().GetAgent(session.GetSessionId())