Пример #1
0
 protected override void OnUpdate()
 {
     // Destroy singleton to prevent system from running again
     EntityManager.DestroyEntity(GetSingletonEntity <InitGameComponent>());
     foreach (World world in World.All)
     {
         NetworkStreamReceiveSystem network = world.GetExistingSystem <NetworkStreamReceiveSystem>();
         if (world.GetExistingSystem <ClientSimulationSystemGroup>() != null)
         {
             // Client worlds automatically connect to localhost
             NetworkEndPoint ep = NetworkEndPoint.LoopbackIpv4;
             ep.Port = 7979;
             network.Connect(ep);
         }
         #if UNITY_EDITOR
         else if (world.GetExistingSystem <ServerSimulationSystemGroup>() != null)
         {
             // Server world automatically listens for connections from any host
             NetworkEndPoint ep = NetworkEndPoint.AnyIpv4;
             ep.Port = 7979;
             network.Listen(ep);
         }
         #endif
     }
 }
Пример #2
0
        protected override void OnUpdate()
        {
            NetworkStreamReceiveSystem network = World.GetExistingSystem <NetworkStreamReceiveSystem>();
            NetworkEndPoint            ep      = NetworkEndPoint.AnyIpv4;

            ep.Port = 21650;
            network.Listen(ep);
            Debug.Log("Lobby Listening on 21650");
            Enabled = false;
        }
Пример #3
0
        // Server world automatically listens for connections from any host
        private bool StartListenConnections(NetworkStreamReceiveSystem network, ushort port)
        {
            NetworkEndPoint ep = NetworkEndPoint.AnyIpv4;

            ep.Port = port;

            var listenStatus = network.Listen(ep);

            Debug.Log($"StartListenConnections({ep.Address}) => {listenStatus}");

            return(listenStatus);
        }