Наследование: Microsoft.AspNet.SignalR.Hubs.Hub
Пример #1
0
        internal static void OnSample(int id)
        {
            var states = Connections.Select(c => c.State);

            var statesArr = new int[3]
            {
                states.Where(s => s == ConnectionState.Connected).Count(),
                states.Where(s => s == ConnectionState.Reconnecting).Count(),
                states.Where(s => s == ConnectionState.Disconnected).Count()
            };

            if (ControllerProxy != null)
            {
                ControllerProxy.Invoke("Mark", id, statesArr);
            }
            else
            {
                ControllerHub.MarkInternal(id, statesArr);
            }

            if (!Arguments.IsController)
            {
                Console.WriteLine("{0} Connected, {1} Reconnected, {2} Disconnected", statesArr[0], statesArr[1], statesArr[2]);
            }
        }
Пример #2
0
        private static void SignalSample(TimeSpan timestamp)
        {
            Samples.Add(new ConnectionsSample(Enum.GetName(typeof(ControllerEvents), TestPhase), timestamp, PerformanceCounters.ServerAvailableMBytes, PerformanceCounters.ServerTcpConnectionsEst));

            if (PerformanceCounters.SignalRCountersAvailable)
            {
                ControllerHub.MarkInternal(Samples.Count - 1, new int[] {
                    PerformanceCounters.SignalRConnectionsCurrent,
                    PerformanceCounters.SignalRConnectionsReconnected,
                    PerformanceCounters.SignalRConnectionsDisconnected
                });
            }
            else
            {
                // Use client connection states
                if (AppHost == null)
                {
                    Client.OnSample(Samples.Count - 1);
                }
                else
                {
                    BroadcastEvent(ControllerEvents.Sample, Samples.Count - 1);
                }
            }
        }
Пример #3
0
        public static void Main()
        {
            Arguments = CrankArguments.Parse();

            ThreadPool.SetMinThreads(Arguments.Connections, 2);
            TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;

            if (Arguments.IsController)
            {
                ControllerHub.Start(Arguments);
            }

            Run().Wait();
        }