/// <summary> Loop for sending data to connected clients. @Todo: Pool this. </summary> private void SendLoop() { while (Running) { SendPass(); ThreadUtil.Hold(1); } string id = isSlave ? "Slave" : "Master"; Log.Info($"SendLoop Ending for {id}"); }
/// <summary> Loop for recieving data from connected clients. @Todo: Pool this. </summary> private void RecrLoop() { while (Running) { try { RecrPass(); } catch (Exception e) { Log.Error("Failure in Server.RecrLoop", e); } ThreadUtil.Hold(1); } string id = isSlave ? "Slave" : "Master"; Log.Info($"RecrLoop Ending for {id}"); }
private void GlobalUpdateLoop() { long i = 0; while (Running) { GlobalUpdatePass(); // Log.Info($"On update tick {i}"); i++; ThreadUtil.Hold(1); } string id = isSlave ? "Slave" : "Master"; Log.Info($"Updates stopping for {id} and cleaning up."); //Todo: Cleanup work }
private void GlobalUpdate() { while (Running) { try { RPCMessage msg; while (incoming.TryDequeue(out msg)) { if (msg.sender.closed) { // early break??? // maybe we still want to handle messages when closed // eg, ServerShuttingDown } HandleMessage(msg); } HandleInternalEvents(); } catch (Exception e) { Log.Error("Failure in Server.GlobalUpdate during Handlers: ", e); } DateTime now = DateTime.UtcNow; TimeSpan diff = now - lastTick; try { if (diff.TotalMilliseconds > tickRate) { lastTick = now; float d = (float)diff.TotalSeconds; foreach (var pair in services) { pair.Value.OnTick(d); } } } catch (Exception e) { Log.Error("Failure in Server.GlobalUpdate during Ticks: ", e); } ThreadUtil.Hold(1); } string id = isSlave ? "Slave" : "Master"; Log.Info($"Updates stopping for {id} and cleaning up."); //Todo: Cleanup work }
/// <summary> Loop for recieving data from connected clients. @Todo: Pool this. </summary> private void RecrLoop() { while (Running) { try { Client c; if (recrCheckQueue.TryDequeue(out c)) { RecieveData(c); if (!c.closed) { recrCheckQueue.Enqueue(c); } } } catch (Exception e) { Log.Error("Failure in Server.RecrLoop", e); } ThreadUtil.Hold(1); } string id = isSlave ? "Slave" : "Master"; Log.Info($"RecrLoop Ending for {id}"); }