本文整理汇总了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));
}
}
示例2: SignalRLogSink
public SignalRLogSink(IHubContext context, IFormatProvider formatProvider)
{
if (context == null) throw new ArgumentNullException(nameof(context));
_formatProvider = formatProvider;
_context = context;
}
示例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);
}
});
}
示例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);
}
示例5: DemoHub
public DemoHub(
IHubContext<TypedDemoHub, IClient> typedDemoContext,
IPersistentConnectionContext<RawConnection> rawConnectionContext)
{
_typedDemoContext = typedDemoContext;
_rawConnectionContext = rawConnectionContext;
}
示例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);
}
}
}
}
}
示例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;
}
示例8: ProxyWatcher
private ProxyWatcher(IHubContext context)
{
Context = context;
_GatewayServer.ClientManager.OnClientConnectEvent += ClientManager_OnClientConnectEvent;
_GatewayServer.ClientManager.OnClientDisconnectEvent += ClientManager_OnClientDisconnectEvent;
_GatewayServer.ClientManager.OnPairedEvent += ClientManager_OnPairedEvent;
}
示例9: AlarmCheck
public AlarmCheck(string UserId, string UserName)
{
_userId = UserId;
_userName = UserName;
_alarmHub = GlobalHost.ConnectionManager.GetHubContext<AlarmHub>();
StartTimer();
}
示例10: ShapeBroadCaster
public ShapeBroadCaster()
{
var broadCastLoop = new Timer(UpdateShape, null, BroadCastInterval, BroadCastInterval);
shouldUpdateShape = false;
shapeHub = GlobalHost.ConnectionManager.GetHubContext<MoveShapeHub>();
}
示例11: BackgroundServerTimeTimer
public BackgroundServerTimeTimer()
{
HostingEnvironment.RegisterObject(this);
hub = GlobalHost.ConnectionManager.GetHubContext<ClientPushHub>();
taskTimer = new Timer(OnTimerElapsed, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(5));
}
示例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));
}
示例13: DataEngine
public DataEngine(int pollIntervalMillis)
{
//HostingEnvironment.RegisterObject(this);
_hubs = GlobalHost.ConnectionManager.GetHubContext<DataHub>();
_pollIntervalMillis = pollIntervalMillis;
dataRandom = new Random(DateTime.Now.Millisecond);
}
示例14: RandomGenerator
public RandomGenerator(int pollIntervalMillis)
{
//HostingEnvironment.RegisterObject(this);
_hubs = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
_pollIntervalMillis = pollIntervalMillis;
_numberRand = new Random();
}
示例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>();
}