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; }
public Game(Client opponent) { this.opponent = opponent; this.field = new Field(); my_turn = false; ships = 10; }
public Game LetsPlay(Client opponent) { if (!HaveGame) { _game = new Game(opponent); } _ready = false; return new Game(this); }
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) { } } }
public void JoinTo(Client opponent) { _game = opponent.LetsPlay(this); _ready = false; }