public CaClient(TcpClient cli, TasClient tas) { try { con = new ClientConnection(); con.ConnectionClosed += con_ConnectionClosed; con.CommandRecieved += con_CommandRecieved; this.tas = tas; tas.BattleUserJoined += tas_BattleUserJoined; tas.BattleInfoChanged += tas_BattleInfoChanged; con.Connect(cli); } catch (Exception ex) { Console.Error.WriteLine(ex); throw; } }
public void Dispose() { try { if (tas != null) { tas.BattleUserJoined -= tas_BattleUserJoined; tas.BattleInfoChanged -= tas_BattleInfoChanged; tas = null; } if (con != null) { con.ConnectionClosed -= con_ConnectionClosed; con.CommandRecieved -= con_CommandRecieved; con.Dispose(); con = null; } } catch (Exception ex) { Console.Error.WriteLine(ex); } }