예제 #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)
}