示例#1
0
文件: Agent.go 项目: cokeboL/GoWorld
func NewAgent(addr string, stype uint32, timerName string) (*Client, uint32) {
	agentClient := newAgentClient(addr)

	if agentClient == nil {
		return nil, ErrConf.AGENT_ERR
	}

	timerMgr := Timer.NewTimerMgr(int64(time.Second))
	timer := timerMgr.NewTimer(timerName, int64(NetConf.HEARTBEART_TIME), func() {
		agentClient.HeartBeat()
	}, true)

	agentClient.AddCloseCB("courierClose", func(client *Client) {
		Logger.Print("Courier ServerJob", LogConf.SERVER, "xxxxxxxxxx 111111  courierClose")
		timerMgr.DeleteTimer(timer)
		go NewAgent(addr, stype, timerName)
	})

	go func() {
		time.Sleep(time.Second / 10)
		agentClient.Regist(stype)
	}()

	return agentClient, 0
}
示例#2
0
文件: Commen.go 项目: cokeboL/ZIM
func init() {
	agentHeartbeatTmer = Timer.NewTimerMgr(int64(time.Second))
	AddMsgHandler(MsgConf.HeartBeat, handleHeartBeat)
	AddMsgHandler(MsgConf.HeartBeat2, handleHeartBeat2)
	AddMsgHandler(MsgConf.ClientHeartBeat, handleClientHeartBeat)
}