public Repeater(Route route, RequestAdapterSocket req) { mRoute = route; mRequest = req; var repeat = req.Message.repeat; mFrom = repeat.skip; mTo = repeat.samples != int.MaxValue ? mFrom + repeat.samples : int.MaxValue; mFreq = repeat.freq; mRequest.Info("repeating"); }
//---------------------------------------------------------------------------------------------------- // process any message queue on the game thread public void Tick() { mSocket.Tick(); if (mRepeaters.Count > 0) { foreach (var repeater in mRepeaters) { repeater.Tick(); } mRepeaters.RemoveAll(r => r.IsFinished); } lock ( mMessageQueue ) { if (mMessageQueue.Count == 0) { return; } // dispatch one message per frame var msg = mMessageQueue[0]; mMessageQueue.RemoveAt(0); // bind socket msg.Socket = this; // find route var route = Unium.RoutesSocket.Find(msg.Path); if (route == null || route.Handler == null) { msg.Error(ResponseCode.NotFound); return; } // create request var req = new RequestAdapterSocket(msg); // queue for repetition? if (msg.repeat != null) { route.SetCacheContext(req, msg.repeat.cache ? 1 : 0); mRepeaters.Add(new Repeater(route, req)); } // otherwise just dispatch else { route.Dispatch(req); } } }