Exemplo n.º 1
0
        void Start()
        {
            CurrentGameState = GameState.Lobby;

            m_Driver = NetworkDriver.Create();
            var endpoint = NetworkEndPoint.AnyIpv4;

            endpoint.Port = 9000;

            if (m_Driver.Bind(endpoint) != 0)
            {
                Debug.Log("Failed to bind to port 9000");
            }
            else
            {
                m_Driver.Listen();
            }


            m_Connections = new NativeList <NetworkConnection>(16, Allocator.Persistent);

            aliveMessage = new GameObject().AddComponent <AliveMessageHandler>();
            aliveMessage.InitializeMessage(3f, false);
            aliveMessage.gameObject.name = "AliveMessage_Server";
            DontDestroyOnLoad(aliveMessage);
        }
Exemplo n.º 2
0
        void Start()
        {
            CurrentGameState = GameState.Lobby;

            m_Driver     = NetworkDriver.Create();
            m_Connection = default(NetworkConnection);

            if (!IsLocal)
            {
                var endpoint = NetworkEndPoint.Parse(IP, Port);
                m_Connection = m_Driver.Connect(endpoint);
            }
            else
            {
                var endpoint = NetworkEndPoint.LoopbackIpv4;
                endpoint.Port = 9000;
                m_Connection  = m_Driver.Connect(endpoint);
            }

            aliveMessage = new GameObject().AddComponent <AliveMessageHandler>();
            aliveMessage.InitializeMessage(3f, true);
            aliveMessage.gameObject.name = "AliveMessage_Client";
            DontDestroyOnLoad(aliveMessage);
        }