internal SocketConnectionListener(
            EndPoint endpoint,
            SocketTransportOptions options,
            ISocketsTrace trace)
        {
            EndPoint    = endpoint;
            _trace      = trace;
            _options    = options;
            _memoryPool = _options.MemoryPoolFactory();
            var ioQueueCount = options.IOQueueCount;

            if (ioQueueCount > 0)
            {
                _numSchedulers = ioQueueCount;
                _schedulers    = new IOQueue[_numSchedulers];

                for (var i = 0; i < _numSchedulers; i++)
                {
                    _schedulers[i] = new IOQueue();
                }
            }
            else
            {
                var directScheduler = new PipeScheduler[] { PipeScheduler.ThreadPool };
                _numSchedulers = directScheduler.Length;
                _schedulers    = directScheduler;
            }
        }
Пример #2
0
        internal SocketTransport(
            IEndPointInformation endPointInformation,
            IConnectionDispatcher dispatcher,
            IApplicationLifetime applicationLifetime,
            int ioQueueCount,
            ISocketsTrace trace)
        {
            Debug.Assert(endPointInformation != null);
            Debug.Assert(endPointInformation.Type == ListenType.IPEndPoint);
            Debug.Assert(dispatcher != null);
            Debug.Assert(applicationLifetime != null);
            Debug.Assert(trace != null);

            _endPointInformation = endPointInformation;
            _dispatcher          = dispatcher;
            _appLifetime         = applicationLifetime;
            _trace = trace;

            if (ioQueueCount > 0)
            {
                _numSchedulers = ioQueueCount;
                _schedulers    = new IOQueue[_numSchedulers];

                for (var i = 0; i < _numSchedulers; i++)
                {
                    _schedulers[i] = new IOQueue();
                }
            }
            else
            {
                _numSchedulers = ThreadPoolSchedulerArray.Length;
                _schedulers    = ThreadPoolSchedulerArray;
            }
        }
Пример #3
0
        internal QuicTransport(
            IEndPointInformation endPointInformation,
            IConnectionDispatcher dispatcher,
            IApplicationLifetime applicationLifetime,
            int ioQueueCount,
            ILogger logger)
        {
            _endPointInformation = endPointInformation;
            _dispatcher          = dispatcher;
            _applicationLifetime = applicationLifetime;
            _logger = logger;

            if (ioQueueCount > 0)
            {
                _numSchedulers = ioQueueCount;
                _schedulers    = new IOQueue[_numSchedulers];

                for (var i = 0; i < _numSchedulers; i++)
                {
                    _schedulers[i] = new IOQueue();
                }
            }
            else
            {
                _numSchedulers = ThreadPoolSchedulerArray.Length;
                _schedulers    = ThreadPoolSchedulerArray;
            }
        }
Пример #4
0
 public MultiIOQueueGroup()
 {
     ioQueues = new IOQueue[DefaultIOQueueCount];
     for (int i = 0; i < DefaultIOQueueCount; i++)
     {
         ioQueues[i] = new IOQueue();
     }
 }
 public TcpHandler(IOQueue queue, Socket socket = null) : base(queue)
 {
     if (socket == null)
     {
         _socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
     }
     else
     {
         _socket = socket;
     }
 }
Пример #6
0
 /// <summary>
 /// Updates the AuthServer about the login-status of the account with the given name.
 /// Accounts that are flagged as logged-in cannot connect again until its unset again.
 /// Called whenever client connects/disconnects.
 /// </summary>
 /// <param name="acc"></param>
 /// <param name="loggedIn"></param>
 internal void SetAccountLoggedIn(RealmAccount acc, bool loggedIn)
 {
     if (m_authServiceClient.IsConnected)
     {
         if (loggedIn)
         {
             acc.OnLogin();
             m_authServiceClient.Channel.SetAccountLoggedIn(acc.Name);
         }
         else
         {
             acc.OnLogout();
             IOQueue.AddMessage(new Message1 <RealmAccount>(acc, UnregisterAccount));
             m_authServiceClient.Channel.SetAccountLoggedOut(acc.Name);
         }
     }
 }
Пример #7
0
        public void Setup()
        {
            _parallelAction = ParallelBody;
            _action         = new Action <object>(ScheduledAction);

            _inlineSchedulers = new PipeScheduler[IOQueueCount];
            for (var i = 0; i < _inlineSchedulers.Length; i++)
            {
                _inlineSchedulers[i] = PipeScheduler.Inline;
            }

            _threadPoolSchedulers = new PipeScheduler[IOQueueCount];
            for (var i = 0; i < _threadPoolSchedulers.Length; i++)
            {
                _threadPoolSchedulers[i] = PipeScheduler.ThreadPool;
            }

            _ioQueueSchedulers = new PipeScheduler[IOQueueCount];
            for (var i = 0; i < _ioQueueSchedulers.Length; i++)
            {
                _ioQueueSchedulers[i] = new IOQueue();
            }
        }
Пример #8
0
        /// <summary>
        ///
        /// </summary>
        protected override void OnShutdown()
        {
            World.Broadcast("Initiating Shutdown...");
            World.Broadcast("Halting server and saving World...");

            World.Save(true);

            if (RealmServerConfiguration.Instance.AutoSave)
            {
                RealmServerConfiguration.Instance.Save(true, true);
            }

            World.Broadcast("World saved.");

            if (m_authServiceClient != null && m_authServiceClient.IsConnected)
            {
                // unset all accounts
                IOQueue.AddMessageAndWait(true, () => m_authServiceClient.Channel.SetAllActiveAccounts(EmptyStringArr));
                Thread.Sleep(100);                              // sleep for a short while to let the client send the msg to the AuthServer
                m_authServiceClient.IsRunning = false;
            }
            World.Broadcast("Shutting down...");
        }
Пример #9
0
        internal SocketTransport(
            IEndPointInformation endPointInformation,
            IConnectionDispatcher dispatcher,
            IHostApplicationLifetime applicationLifetime,
            int ioQueueCount,
            ISocketsTrace trace,
            MemoryPool <byte> memoryPool)
        {
            Debug.Assert(endPointInformation != null);
            Debug.Assert(endPointInformation.Type == ListenType.IPEndPoint);
            Debug.Assert(dispatcher != null);
            Debug.Assert(applicationLifetime != null);
            Debug.Assert(trace != null);

            _endPointInformation = endPointInformation;
            _dispatcher          = dispatcher;
            _appLifetime         = applicationLifetime;
            _trace      = trace;
            _memoryPool = memoryPool;

            if (ioQueueCount > 0)
            {
                _numSchedulers = ioQueueCount;
                _schedulers    = new IOQueue[_numSchedulers];

                for (var i = 0; i < _numSchedulers; i++)
                {
                    _schedulers[i] = new IOQueue();
                }
            }
            else
            {
                var directScheduler = new PipeScheduler[] { PipeScheduler.ThreadPool };
                _numSchedulers = directScheduler.Length;
                _schedulers    = directScheduler;
            }
        }
Пример #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 public override void Dispatch(string message)
 {
     IOQueue.AddMessage(() => base.Dispatch(message));
 }
Пример #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="method"></param>
 public override void RemoveHandler(Action <string> method)
 {
     IOQueue.AddMessage(() => base.RemoveHandler(method));
 }
Пример #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="method"></param>
 public new void AddHandler(Action <string> method)
 {
     IOQueue.AddMessage(() => base.AddHandler(method));
 }