コード例 #1
0
    bool StartupPeer()
    {
        m_cRnPeer = new RakNet.RakPeer();
        m_usPort  = (ushort)UnityEngine.Random.Range(10000, 30000);


        RakNet.SocketDescriptor tSocketDesc    = new RakNet.SocketDescriptor((ushort)m_usPort, "");
        RakNet.StartupResult    eStartupResult = m_cRnPeer.Startup(1, tSocketDesc, 1);
        bool bPeerStarted = false;


        if (eStartupResult != RakNet.StartupResult.RAKNET_STARTED)
        {
            Logger.WriteError("Raknet peer failed to start. ErrorCode({0}) Port({1})", eStartupResult, m_usPort);
        }
        else
        {
            bPeerStarted = true;
            m_cRnPeer.SetOccasionalPing(true);

            Logger.Write("Raknet peer started. Port({0})", m_usPort);
        }


        return(bPeerStarted);
    }
コード例 #2
0
    bool StartupPeer(uint _uiNumSlots)
    {
        //m_cRnPeer = RakNet.RakPeerInterface.GetInstance();
        m_cRnPeer = new RakNet.RakPeer();


        RakNet.SocketDescriptor tSocketDesc    = new RakNet.SocketDescriptor((ushort)m_usPort, "");
        RakNet.StartupResult    eStartupResult = m_cRnPeer.Startup(_uiNumSlots, tSocketDesc, 1);
        bool bPeerStarted = false;


        if (eStartupResult != RakNet.StartupResult.RAKNET_STARTED)
        {
            Logger.WriteError("Raknet peer failed to start. ErrorCode({0})", eStartupResult);
        }
        else
        {
            m_cRnPeer.SetMaximumIncomingConnections((ushort)_uiNumSlots);
            m_cRnPeer.SetOccasionalPing(true);
            SendCounter  = 0;
            bPeerStarted = true;


            Logger.Write("Server started with port ({0}) NumSlots({1})", m_usPort, _uiNumSlots);
        }

        return(bPeerStarted);
    }
コード例 #3
0
ファイル: CNetworkConnection.cs プロジェクト: nulhax/VOID
    bool StartupPeer()
    {
        m_cRnPeer = new RakNet.RakPeer();
        m_usPort = (ushort)UnityEngine.Random.Range(10000, 30000);


        RakNet.SocketDescriptor tSocketDesc = new RakNet.SocketDescriptor((ushort)m_usPort, "");
        RakNet.StartupResult eStartupResult = m_cRnPeer.Startup(1, tSocketDesc, 1);
        bool bPeerStarted = false;


        if (eStartupResult != RakNet.StartupResult.RAKNET_STARTED)
        {
            Logger.WriteError("Raknet peer failed to start. ErrorCode({0}) Port({1})", eStartupResult, m_usPort);
        }
        else
        {
            bPeerStarted = true;
			m_cRnPeer.SetOccasionalPing(true);

            Logger.Write("Raknet peer started. Port({0})", m_usPort);
        }


        return (bPeerStarted);
    }
コード例 #4
0
ファイル: CNetworkServer.cs プロジェクト: nulhax/VOID
    bool StartupPeer(uint _uiNumSlots)
    {
        //m_cRnPeer = RakNet.RakPeerInterface.GetInstance();
        m_cRnPeer = new RakNet.RakPeer();


        RakNet.SocketDescriptor tSocketDesc = new RakNet.SocketDescriptor((ushort)m_usPort, "");
        RakNet.StartupResult eStartupResult = m_cRnPeer.Startup(_uiNumSlots, tSocketDesc, 1);
        bool bPeerStarted = false;


        if (eStartupResult != RakNet.StartupResult.RAKNET_STARTED)
        {
            Logger.WriteError("Raknet peer failed to start. ErrorCode({0})", eStartupResult);
        }
        else
        {
            m_cRnPeer.SetMaximumIncomingConnections((ushort)_uiNumSlots);
			m_cRnPeer.SetOccasionalPing(true);
			SendCounter = 0;
            bPeerStarted = true;


            Logger.Write("Server started with port ({0}) NumSlots({1})", m_usPort, _uiNumSlots);
        }

        return (bPeerStarted);
    }