Ejemplo n.º 1
0
        private void DestroyNetwork()
        {
            if (host != null)
            {
                DisconnectAll();
                ENet.DestroyHost(host);
                connections = null;
                host        = null;
            }
            IncomingMessage stoppedEvent = GetIncomingMessage();

            stoppedEvent.Event = EventMessage.NetworkStopped;
            IncomingEnqueue(stoppedEvent);
        }
Ejemplo n.º 2
0
        private void Initialize()
        {
            ENet.Initialize();

            InitializePools();
            InitializeQueues(config.IncomingBufferSize);

            connections = new RemoteConnection[config.MaxConnections];

            if (config.AllowConnectors)
            {
                ENet.Address address = new ENet.Address();
                address.Port = config.Port;


                ENet.AddressSetHost(ref address, config.LocalAddress);
                host = ENet.CreateHost(ref address, (IntPtr)config.MaxConnections, (IntPtr)config.MaxConnections, config.IncomingBandwidth, config.OutgoingBandwidth, config.AppIdentification);
            }
            else
            {
                host = ENet.CreateHost(null, (IntPtr)config.MaxConnections, (IntPtr)config.MaxConnections, config.IncomingBandwidth, config.OutgoingBandwidth, config.AppIdentification);
            }

            if (host == null)
            {
                Debug.Error(config.Name, ": Failed to create host");
                return;
            }

            IncomingMessage readyEvent = GetIncomingMessage();

            readyEvent.Event = EventMessage.NetworkReady;
            IncomingEnqueue(readyEvent);

            isRunning   = true;
            isConfigSet = false;
        }
Ejemplo n.º 3
0
 internal NATServerConnection(ENet.Host *host, IPEndPoint target)
 {
     Host     = host;
     endPoint = target;
     Peer     = null;
 }