Пример #1
0
func Run() {
	go timeTick()
	for tm := range changes {
		if len(tm.Key) != 0 && online.GetCurrentTime().Before(tm.Time) { //push time
			online.SetCurrentTime(tm.Time)
		}

		//两种情况,实时推送(pushdelay==0 ,tm是由数据推送的,key不为空);定时推送(pushdelay>0 并超时,不考虑key);
		if PushDelay == 0 && len(tm.Key) != 0 || PushDelay > 0 && time.Since(delayTime).Seconds() >= PushDelay {
			delayTime = time.Now()
			tm.Time = online.GetCurrentTime()
			//log.Infof("now push data @ ", tm.Key, tm.Time)
			online.SendTimeMessageToAll(tm)
		}
	}
}
Пример #2
0
//注册推送数据的请求
func pid2(cmd *common.RequestData, c *online.Client) {
	if checkParamError(cmd, c, "DataKey", "DataRange", "Id", "LimitId", "OrderBy", "OrderKey", "OutputKey", "TimeRange") {
		return
	}
	dp := new(common.DataParam)
	dp.DataKey = cmd.GetString("DataKey")
	dp.DataRange = cmd.GetInt("DataRange")
	dp.Id = cmd.GetString("Id")
	dp.LimitId = cmd.GetStringArray("LimitId")
	dp.OrderBy = cmd.GetInt("OrderBy")
	dp.OrderKey = cmd.GetString("OrderKey")
	dp.OutputKey = cmd.GetStringArray("OutputKey")
	dp.FillKey = cmd.GetString("FillKey")
	dp.TimeRange = cmd.GetInt("TimeRange")
	c.AddRequest(dp)
	//同时直接返回一次数据,否则界面会有空白期
	tm := &common.TimeMessage{Time: online.GetCurrentTime()}
	c.Processing(tm)
}