Exemple #1
0
 public NtpSyncModule(string ntpServer)
 {
     _ntpEndPoint = new NetEndPoint(ntpServer, 123);
     _socket      = new NetSocket(OnMessageReceived);
     _socket.Bind(0, false);
     SyncedTime = null;
 }
        /// <summary>
        /// NetManager constructor
        /// </summary>
        /// <param name="listener">Network events listener</param>
        /// <param name="maxConnections">Maximum connections (incoming and outcoming)</param>
        /// <param name="connectKey">Application key (must be same with remote host for establish connection)</param>
        public NetManager(INetEventListener listener, int maxConnections, string connectKey)
        {
            _logicThread      = new NetThread("LogicThread", DefaultUpdateTime, UpdateLogic);
            _socket           = new NetSocket(ReceiveLogic);
            _netEventListener = listener;
            _flowModes        = new List <FlowMode>();
            _netEventsQueue   = new Queue <NetEvent>();
            _netEventsPool    = new Stack <NetEvent>();
            _netPacketPool    = new NetPacketPool();
            NatPunchModule    = new NatPunchModule(this);

            _connectKey     = connectKey;
            _peers          = new NetPeerCollection(maxConnections);
            _maxConnections = maxConnections;
            _connectKey     = connectKey;
        }