当前位置: 首页>>代码示例>>C#>>正文


C# IHubContext类代码示例

本文整理汇总了C#中IHubContext的典型用法代码示例。如果您正苦于以下问题:C# IHubContext类的具体用法?C# IHubContext怎么用?C# IHubContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IHubContext类属于命名空间,在下文中一共展示了IHubContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ForGame

 private static void ForGame(Guid gameId, IHubContext ctx, Action<dynamic> actionOnValidClient)
 {
     foreach (var registration in Registry.ClientToGames.Where(x => x.Value == gameId))
     {
         actionOnValidClient(ctx.Clients().Client(registration.Key));
     }
 }
开发者ID:davidwhitney,项目名称:StarBastardCore,代码行数:7,代码来源:ClientPushHub.cs

示例2: SignalRLogSink

        public SignalRLogSink(IHubContext context, IFormatProvider formatProvider)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            _formatProvider = formatProvider;
            _context = context;
        }
开发者ID:eugene-goldberg,项目名称:StandaloneServiceTemplate,代码行数:7,代码来源:SignalRLogSink.cs

示例3: QueueProcessor

        public QueueProcessor(Logger log, IDataStore dataStore, IHubContext<IMatchmakingClient> hub, ITracker tracker, IMatchEvaluator matchBuilder, CircularBuffer<TimeSpan> timeToMatch)
        {
            _log = log;
            _dataStore = dataStore;
            _hub = hub;
            _tracker = tracker;
            _matchBuilder = matchBuilder;
            _timeToMatch = timeToMatch;

            _queueSleepMin = Int32.Parse( CloudConfigurationManager.GetSetting("QueueSleepMin") );
            _queueSleepMax = Int32.Parse( CloudConfigurationManager.GetSetting("QueueSleepMax") );
            _queueSleepLength = Int32.Parse( CloudConfigurationManager.GetSetting("QueueSleepLength") );

            Task.Run( async () =>
            {
                _log.Info("Running QueueProcessor...");

                while( true )
                {
                    var sleepTime = _queueSleepMax;

                    try
                    {
                        await processQueue();
                        sleepTime = _queueSleepMax - (_dataStore.DocumentDbPopulation * (_queueSleepMax/_queueSleepLength));
                    }
                    catch(Exception ex)
                    {
                        _log.Error(ex);
                    }

                    Thread.Sleep(sleepTime < _queueSleepMin ? _queueSleepMin : sleepTime);
                }
            });
        }
开发者ID:spencerhakim,项目名称:firetea.ms,代码行数:35,代码来源:QueueProcessor.cs

示例4: SignalR

        /// <summary>
        /// Adds a sink that writes log events as documents to a SignalR hub.
        /// 
        /// </summary>
        /// <param name="loggerConfiguration">The logger configuration.</param><param name="context">The hub context.</param><param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param><param name="batchPostingLimit">The maximum number of events to post in a single batch.</param><param name="period">The time to wait between checking for event batches.</param><param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
        /// <returns>
        /// Logger configuration, allowing configuration to continue.
        /// </returns>
        /// <exception cref="T:System.ArgumentNullException">A required parameter is null.</exception>
        public static LoggerConfiguration SignalR(this LoggerSinkConfiguration loggerConfiguration, IHubContext context, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose, int batchPostingLimit = 5, TimeSpan? period = null, IFormatProvider formatProvider = null)
        {
            if (loggerConfiguration == null) throw new ArgumentNullException(nameof(loggerConfiguration));
            if (context == null) throw new ArgumentNullException(nameof(context));

            return loggerConfiguration.Sink(new SignalRLogSink(context, formatProvider), restrictedToMinimumLevel);
        }
开发者ID:eugene-goldberg,项目名称:StandaloneServiceTemplate,代码行数:16,代码来源:SignalRLogSinkExtensions.cs

示例5: DemoHub

 public DemoHub(
     IHubContext<TypedDemoHub, IClient> typedDemoContext,
     IPersistentConnectionContext<RawConnection> rawConnectionContext)
 {
     _typedDemoContext = typedDemoContext;
     _rawConnectionContext = rawConnectionContext;
 }
开发者ID:leloulight,项目名称:SignalR-Server,代码行数:7,代码来源:DemoHub.cs

示例6: DeleteSessionMessageTutor

        public void DeleteSessionMessageTutor(string sessionId, string sendTo, string message, IHubContext context)
        {
            //var name = Context.User.Identity.Name;
            using (var db = new ApplicationDbContext())
            {
                var user = db.Useras.Where(c => c.UserName == sendTo && c.SessionId == sessionId).FirstOrDefault();
                if (user == null)
                {
                    // context.Clients.Caller.showErrorMessage("Could not find that user.");
                }
                else
                {
                    db.Entry(user)
                        .Collection(u => u.Connections)
                        .Query()
                        .Where(c => c.Connected == true)
                        .Load();

                    if (user.Connections == null)
                    {
                        //  Clients.Caller.showErrorMessage("The user is no longer connected.");
                    }
                    else
                    {
                        foreach (var connection in user.Connections)
                        {
                            context.Clients.Client(connection.ConnectionID)
                                 .recieverSessionClosed(message);
                        }
                    }
                }
            }
        }
开发者ID:imranjaved728,项目名称:MezoExpert,代码行数:33,代码来源:StudentsController.cs

示例7: SignalRSink

 /// <summary>
 /// Construct a sink posting to the specified database.
 /// </summary>
 /// <param name="context">The hub context.</param>
 /// <param name="batchPostingLimit">The maximium number of events to post in a single batch.</param>
 /// <param name="period">The time to wait between checking for event batches.</param>
 /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
 public SignalRSink(IHubContext context, int batchPostingLimit, TimeSpan period, IFormatProvider formatProvider)
     : base(batchPostingLimit, period)
 {
     if (context == null)
         throw new ArgumentNullException("context");
     _formatProvider = formatProvider;
     _context = context;
 }
开发者ID:RossMerr,项目名称:serilog,代码行数:15,代码来源:SignalRSink.cs

示例8: ProxyWatcher

        private ProxyWatcher(IHubContext context)
        {
            Context = context;

            _GatewayServer.ClientManager.OnClientConnectEvent += ClientManager_OnClientConnectEvent;
            _GatewayServer.ClientManager.OnClientDisconnectEvent += ClientManager_OnClientDisconnectEvent;
            _GatewayServer.ClientManager.OnPairedEvent += ClientManager_OnPairedEvent;
        }
开发者ID:jaganthoutam,项目名称:RemoteDesktop,代码行数:8,代码来源:ProxyWatcher.cs

示例9: AlarmCheck

 public AlarmCheck(string UserId, string UserName)
 {
     _userId = UserId;
     _userName = UserName;
     _alarmHub = GlobalHost.ConnectionManager.GetHubContext<AlarmHub>();
     StartTimer();
 }
开发者ID:Dierme,项目名称:smartcalendarHELP,代码行数:7,代码来源:AlarmCheck.cs

示例10: ShapeBroadCaster

        public ShapeBroadCaster()
        {
            var broadCastLoop = new Timer(UpdateShape, null, BroadCastInterval, BroadCastInterval);
            shouldUpdateShape = false;

            shapeHub = GlobalHost.ConnectionManager.GetHubContext<MoveShapeHub>();
        }
开发者ID:sujankh,项目名称:LearnSignalR,代码行数:7,代码来源:MoveShapeHub.cs

示例11: BackgroundServerTimeTimer

        public BackgroundServerTimeTimer()
        {
            HostingEnvironment.RegisterObject(this);

            hub = GlobalHost.ConnectionManager.GetHubContext<ClientPushHub>();
            taskTimer = new Timer(OnTimerElapsed, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(5));
        }
开发者ID:ChristianWeyer,项目名称:ngSignalR,代码行数:7,代码来源:BackgroundServerTimeTimer.cs

示例12: BackgroundTicker

 public BackgroundTicker(IHubMessageService hubMessageService)
 {
     _hubMessageService = hubMessageService;
     HostingEnvironment.RegisterObject(this);
     hub = GlobalHost.ConnectionManager.GetHubContext<StatsHub>();
     taskTimer = new Timer(OnTimerElasped, null, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2));
 }
开发者ID:bl1nkr,项目名称:AkkaSandbox,代码行数:7,代码来源:StatsHub.cs

示例13: DataEngine

 public DataEngine(int pollIntervalMillis)
 {
     //HostingEnvironment.RegisterObject(this);
     _hubs = GlobalHost.ConnectionManager.GetHubContext<DataHub>();
     _pollIntervalMillis = pollIntervalMillis;
     dataRandom = new Random(DateTime.Now.Millisecond);
 }
开发者ID:mplynch,项目名称:angularRT,代码行数:7,代码来源:DataEngine.cs

示例14: RandomGenerator

 public RandomGenerator(int pollIntervalMillis)
 {
     //HostingEnvironment.RegisterObject(this);
     _hubs = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
     _pollIntervalMillis = pollIntervalMillis;
     _numberRand = new Random();
 }
开发者ID:TkachenkoRoman,项目名称:OwinKatanaServer,代码行数:7,代码来源:RandomGenerator.cs

示例15: SignalRConsole

 public SignalRConsole()
 {
     var url = "http://localhost:8945";
     WebApp.Start<Startup>(url);
     System.Console.WriteLine("Server running on {0}", url);
     _hubContext = GlobalHost.ConnectionManager.GetHubContext<SignalrProxy>();
 }
开发者ID:modulexcite,项目名称:ScriptCs.WebConsole,代码行数:7,代码来源:SignalRConsole.cs


注:本文中的IHubContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。