Exemplo n.º 1
0
        public void SendToClient(PacketFromServer packet)
        {
            if (Phase == Phases.FinalClose)
            {
                return;
            }

#if DEBUG
            /*if (packet is PlayerPositionLook)
             *  Thread.Sleep(50);
             * Thread.Sleep(30);*/
#endif

            //Thread.Sleep(100);
            //Debug.WriteLine(packet);

            //Send possessed packets
            SendToPossessors(packet);

            //Ping update
            KeepAlivePing ka = packet as KeepAlivePing;
            if (ka != null)
            {
                lock (pings)
                {
                    if (pings.ContainsKey(ka.KeepAliveID))
                    {
                        pings.Remove(ka.KeepAliveID);
                    }
                    if (pings.Count > 5)
                    {
                        pings.Clear();
                    }

                    pings.Add(ka.KeepAliveID, DateTime.Now);
                }
            }

            SendToClientInternal(packet);
        }
Exemplo n.º 2
0
 internal static void InvokeKeepAlivePing()
 {
     KeepAlivePing?.Invoke(null, EventArgs.Empty);
 }