Пример #1
0
 private void SecureDeleteClient(Client client)
 {
     clientsDictionary.Remove(client.Name);
     client.LeaveGame();
     bool deleted = client.DeleteRoom();
     if (deleted)
     {
         Console.WriteLine("Client {0} deleted room!", client.Name);
         List<Client> failed = new List<Client>();
         foreach (var iclient in clientsDictionary.Values)
         {
             try
             {
                 iclient.Callback.RoomDeleted(client.Name);
             }
             catch (Exception)
             {
                 failed.Add(client);
             }
         }
         SecureDeleteClients(failed);
     }
     Console.WriteLine("Client {0} leave!", client.Name);
     return;
 }
Пример #2
0
 public Game(Client opponent)
 {
     this.opponent = opponent;
     this.field = new Field();
     my_turn = false;
     ships = 10;
 }
Пример #3
0
 public Game LetsPlay(Client opponent)
 {
     if (!HaveGame)
     {
         _game = new Game(opponent);
     }
     _ready = false;
     return new Game(this);
 }
Пример #4
0
 public void Join(string name)
 {
     if (!clientsDictionary.ContainsKey(name))
     {
         Client newClient = null;
         try
         {
             newClient = new Client(OperationContext.Current.GetCallbackChannel<IClientCallback>(), name);
         }
         catch (Exception)
         {
             Console.WriteLine("Error joining client {0}!", name);
             return;
         }
         clientsDictionary.Add(name, newClient);
         Console.WriteLine("Client {0} joined!", name);
     }
     else
     {
         Console.WriteLine("Someone wants to get the used login {0}!", name);
         try
         {
             OperationContext.Current.GetCallbackChannel<IClientCallback>().UserNameExists();
         }
         catch (Exception) { }
     }
 }
Пример #5
0
 public void JoinTo(Client opponent)
 {
     _game = opponent.LetsPlay(this);
     _ready = false;
 }