/// <summary> /// Aceita o convite de jogo realizado pelo outro jogaor. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_AceitoConv_Click(object sender, EventArgs e) { if (this.foiConvidado) { serverTcp = new ServerTcp(Conecta.PORTA_CONEXAO, this); serverTcp.IniciaServer(); serverUdp.AceitoConvite(); gb_Convite.Enabled = false; gb_ConviteRecv.Visible = false; tm_verJogOn.Stop(); //paro a thread de escuta e envio de broadcast. e atribuo um valor null para poder recomeçar depois a //perquisa por jogadores. this.serverUdp.ParaUdp(); //this.serverUdp = null; } }
private void EncerraConexaoTcp() { if (this.serverTcp != null) { serverTcp.EncerraConexaoTcp(); serverTcp = null; } else if (this.clientTcp != null) { clientTcp.EncerraConexaoTcp(); clientTcp = null; } }
/// <summary> /// Quando a a desistencia do jogador da partida. /// </summary> public void FimDeJogo() { //quando o jogador desiste de jogar. Quando ele desiste, envio uma msg de desistencia e fecha a conexao. //this.euDesisto = true; string msg = "19005"; if (this.serverTcp != null) { this.serverTcp.EnviaMsg(msg); this.serverTcp.EncerraConexaoTcp(); this.serverTcp = null; //Console.WriteLine("Fechou conexao server."); } else if (this.clientTcp != null) { this.clientTcp.EnviaMsg(msg); this.clientTcp.EncerraConexaoTcp(); this.clientTcp = null; //Console.WriteLine("Fechou conexao cliente."); } }