Exemplo n.º 1
0
 /// <summary>
 /// Sends a serializable object to a specific client
 /// </summary>
 /// <param name="serializableObject">The serializable object</param>
 /// <param name="server_ServerClient">The recieving client</param>
 public void Send(object serializableObject, Server_ServerClient server_ServerClient)
 {
     try
     {
         form.Serialize(server_ServerClient.tcp.GetStream(), serializableObject);
     }
     catch (Exception e)
     {
         if (e is IOException || e is InvalidOperationException)
         {
             clientManager.ClientLeft(server_ServerClient);
         }
         else
         {
             clientManager.ClientLeft(server_ServerClient);
             logger.Log("Exception on msg send is caught as general exception! (" + e.ToString() + ")");
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Accumilates up time and then pings clients to verify they are online and calibrate their ping
        /// </summary>
        public void Update()
        {
            accumilatedUpdates++;
            if (accumilatedUpdates >= updatesNeededToPing)
            {
                accumilatedUpdates = 0;

                for (int i = 0; i < clientManager.GetClients().Count; i++)
                {
                    if (clock.GetTime() - clientManager.GetClients()[i].GetLastPingTimeStamp() > (updatesNeededToPing * miliSecondsPerTick * pingsMissedToDropPlayer))
                    {
                        clientManager.ClientLeft(clientManager.GetClients()[i]);
                    }
                    else
                    {
                        SendPing(clientManager.GetClients()[i]);
                    }
                }
            }
        }