Esempio n. 1
0
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
}
Esempio n. 2
0
func init() {
	agentHeartbeatTmer = Timer.NewTimerMgr(int64(time.Second))
	AddMsgHandler(MsgConf.HeartBeat, handleHeartBeat)
	AddMsgHandler(MsgConf.HeartBeat2, handleHeartBeat2)
	AddMsgHandler(MsgConf.ClientHeartBeat, handleClientHeartBeat)
}