Ejemplo n.º 1
0
 public System.Object ServerCommunication(Version clientversion, ICommunicateable communicator, bool full, System.Object obj)
 {
     try
     {
         Player player = (Player)obj;
         if (clientversion.Major > 0)
         {
             lock (SynchronizeRoot)
             {
                 if (full)
                 {
                     // Receive information about the new player.
                     string company = communicator.ReceiveString();
                     string name    = communicator.ReceiveString();
                     // Create the new player.
                     player         = new Player(Players.NextPlayerId, company, name, Stocks, false, false);
                     player.Capital = ((int)System.Math.Round(Players.AverageValue / 1000, 0)) * 1000;
                     player.ValueHistory.Clear();
                     Players.Add(player);
                 }
                 // Send game informations.
                 StockIndexes.ServerCommunication(clientversion, communicator, full, null);
                 Stocks.ServerCommunication(clientversion, communicator, full, StockIndexes);
                 Players.ServerCommunication(clientversion, communicator, full, player.Id);
                 MarketState.ServerCommunication(clientversion, communicator, full, null);
             }
         }
         return(player);
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }