Ejemplo n.º 1
0
        public static void Main()
        {
            if (UPnP.IsAvailable)
            {
                Console.WriteLine($"It worked! Local: {UPnP.LocalIP}, External:{UPnP.ExternalIP}");
            }
            else
            {
                Console.WriteLine("It failed");
            }

            PrintMappings();

            const ushort port = 25000;

            Console.WriteLine($"IsOpen({Protocol.TCP},{port}) --> {UPnP.IsOpen(Protocol.TCP, port)}");

            Console.WriteLine("Opening Port");
            UPnP.Open(Protocol.TCP, port);
            Console.WriteLine("Opened");

            Console.WriteLine($"IsOpen({Protocol.TCP},{port}) --> {UPnP.IsOpen(Protocol.TCP, port)}");

            PrintMappings();

            Console.ReadKey();
            Console.WriteLine("Closing Port");
            UPnP.Close(Protocol.TCP, port);
            Console.WriteLine("Closed");
        }
    /// <summary>
    /// Stop everything.
    /// </summary>

    void Disconnect()
    {
        mGame.Stop();

        if (mLobby != null)
        {
            mLobby.Stop();
            mLobby = null;
        }
        mUp.Close();
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Stop the server.
    /// </summary>

    public void Dispose()
    {
        // Stop the game server
        if (mGameServer != null)
        {
            mGameServer.Stop();
            mGameServer = null;
        }

        // Stop the lobby server
        if (mLobbyServer != null)
        {
            mLobbyServer.Stop();
            mLobbyServer = null;
        }

        // Close all opened ports
        if (mUPnP != null)
        {
            mUPnP.Close();
            mUPnP.WaitForThreads();
            mUPnP = null;
        }
    }
Ejemplo n.º 4
0
 public void Remove(int lExternalPort, string bstrProtocol)
 {
     UPnP.Close(Enum.Parse <Protocol>(bstrProtocol), (ushort)lExternalPort);
 }
Ejemplo n.º 5
0
 private void OnDestroy()
 {
     TcpProtocol.Disconnect();
     UdpProtocol.Stop();
     upnp.Close();
 }