public void FinishConnection(int myPlayerId)
        {
            this.myPlayerId = myPlayerId;
            packetsSender.SendWelcomeReceivedPacket();

            udpConnection = new UdpConnection(this, metaMonoBehaviours, packetsReceiver, GetTcpLocalEndpoint().Port);
        }
        public void Connect()
        {
            tcpConnection = new TcpConnection(this, packetsReceiver, metaMonoBehaviours);
            udpConnection = null;

            IsConnected = true;
        }
        public void Disconnect()
        {
            // This check and this variable is needed, because unity is not Closing instantly on Application.Quit();
            if (!IsConnected)
            {
                return;
            }

            IsConnected = false;

            tcpConnection.tcpClient.Close();
            tcpConnection = null;
            udpConnection.CloseConnection();
            udpConnection = null;

            scenesManager.SwitchScene(Scene.MainMenu);
            playersManager.ClearPlayers();

            Logger.LogEvent(LoggerSection.Connection, "Disconnected from the server");
        }