Exemplo n.º 1
0
        /// <summary>
        /// Bind query and heartbeat listeners to the specified port
        /// </summary>
        /// <param name="listenPort">Port (TCP and UDP) to bind the listeners to</param>
        private void Bind(int listenPort)
        {
            if (queryListeners.ContainsKey(listenPort))
            {
                MasterServer.Log("[NET] Port {0} already bound", listenPort);
                return;
            }

            try
            {
                IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, listenPort);

                QueryListener queryListener = new QueryListener(endpoint, serverList, geoIP, md5Manager, banManager, cdKeyValidator, gameStats);
                queryListeners.Add(listenPort, queryListener);

                HeartbeatListener heartbeatListener = new HeartbeatListener(endpoint);
                heartbeatListener.ReceivedHeartbeat += new ReceivedHeartbeatHandler(serverList.ReceivedHeartbeat);
                heartbeatListeners.Add(listenPort, heartbeatListener);

                MasterServer.Log("[NET] Port {0} bound successfully", listenPort);
            }
            catch (Exception ex)
            {
                MasterServer.Log("[NET] Error binding port(s) {0}, {1}", listenPort, ex.Message);

                queryListeners.Remove(listenPort);
                heartbeatListeners.Remove(listenPort);
            }

            UpdateListenPortList();
        }
        internal static IListener CreateHostListener(IListenerFactory allFunctionsListenerFactory, SharedQueueHandler sharedQueue,
                                                     IRecurrentCommand heartbeatCommand, IWebJobsExceptionHandler exceptionHandler, CancellationToken shutdownToken)
        {
            IListener factoryListener   = new ListenerFactoryListener(allFunctionsListenerFactory, sharedQueue);
            IListener heartbeatListener = new HeartbeatListener(heartbeatCommand, exceptionHandler, factoryListener);
            IListener shutdownListener  = new ShutdownListener(shutdownToken, heartbeatListener);

            return(shutdownListener);
        }
        private static IListener CreateHostListener(IListenerFactory allFunctionsListenerFactory,
                                                    IRecurrentCommand heartbeatCommand, IBackgroundExceptionDispatcher backgroundExceptionDispatcher,
                                                    CancellationToken shutdownToken)
        {
            IListener factoryListener   = new ListenerFactoryListener(allFunctionsListenerFactory);
            IListener heartbeatListener = new HeartbeatListener(heartbeatCommand, backgroundExceptionDispatcher, factoryListener);
            IListener shutdownListener  = new ShutdownListener(shutdownToken, heartbeatListener);

            return(shutdownListener);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Stops CAST communication channels.
        /// </summary>
        public void Stop()
        {
            // Stop heartbeat
            if (_timer != null)
            {
                _timer.Stop();
            }

            HeartbeatListener.Stop();
            SendHeartbeatNowListener.Stop();

            ClientListener.Stop();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Starts CAST communication channels.
        /// </summary>
        public void Start()
        {
            if (CastService.GetIsCastConfigured())
            {
                EventLog.Application.WriteWarning("CAST communications are starting.");

                // Server specific
                if (CastService.GetIsCastServer())
                {
                    HeartbeatListener.Receive <RemotePlatformInfo>(SpecialStrings.CastHeartbeatKey, HandleHeartbeat, false);
                }

                SendHeartbeatNowListener.Subscribe <string>(SpecialStrings.CastHeartbeatDemandKey, SendHeartbeatNow);
                StartHeartbeat();

                ClientListener.Respond <CastRequest, CastResponse>(CastService.GetClientCommunicationKey(), HandleRequest);
            }
        }
Exemplo n.º 6
0
 public override void RemoveHeartbeatListener(HeartbeatListener listener)
 {
     _heartBeatListeners.remove(listener);
 }
Exemplo n.º 7
0
 public override void AddHeartbeatListener(HeartbeatListener listener)
 {
     _heartBeatListeners.add(listener);
 }