/// <summary> /// Do handshake at client client side. /// </summary> private void handShake() { HandShakeProtocol handShakeProtocol = new HandShakeProtocol(); AProtocol protocol = handShakeProtocol.HandShakeClient(COMMUNICATION).Result; if (protocol == null) { disconnect("Handshake fail."); } else { COMMUNICATION.PROTOCOL = protocol; } }
protected async void handshake(NetworkStream sns) { HandShakeProtocol handshakeProtocol = new HandShakeProtocol(); await Task.Yield(); AProtocol protocol = await handshakeProtocol.HandShakeServer(sns); if (protocol == null) { disconnect(sns, "Handshake fail."); } else { sns.PROTOCOL = protocol; await sns.SendCommandAsync(GetGameTypeCommand(Battlefield)); if (!Battlefield.AddRobot(sns)) { disconnect(sns, "Arena is full."); } } }