本文整理汇总了C#中IConnectionManager.GetHubContext方法的典型用法代码示例。如果您正苦于以下问题:C# IConnectionManager.GetHubContext方法的具体用法?C# IConnectionManager.GetHubContext怎么用?C# IConnectionManager.GetHubContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConnectionManager
的用法示例。
在下文中一共展示了IConnectionManager.GetHubContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: playerHub
/// <summary>
/// Constructs the player hub
/// </summary>
/// <param name="manager">The player hub connection manager</param>
public playerHub(IConnectionManager manager)
{
// Make sure the player hub context is avaiable when needed.
serviceHelpers.playerHubContext = manager.GetHubContext<playerHub>();
// Create or get the playerSignals instance
_signals = playerSignals.Instance;
}
示例2: Start
public static void Start(IConnectionManager connectionManager)
{
hub = connectionManager.GetHubContext<DashboardHub>();
SystemController.OnStarted += OnSystemControllerStarted;
SystemController.OnGatewayConnected += OnGatewayConnected;
SystemController.OnGatewayDisconnected += OnGatewayDisconnected;
}
示例3: PresenceMonitor
public PresenceMonitor(IKernel kernel,
IConnectionManager connectionManager,
ITransportHeartbeat heartbeat)
{
_kernel = kernel;
_hubContext = connectionManager.GetHubContext<Chat>();
_heartbeat = heartbeat;
}
示例4: UploadCallbackHandler
public UploadCallbackHandler(UploadProcessor processor,
ContentProviderProcessor resourceProcessor,
IConnectionManager connectionManager,
IChatService service)
{
_processor = processor;
_resourceProcessor = resourceProcessor;
_hubContext = connectionManager.GetHubContext<Chat>();
_service = service;
}
示例5: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app,ILoggerFactory loggerFactory, IHostingEnvironment env,IRuntimeEnvironment runtimeEnv,IConnectionManager connectionManager)
{
app.UseStaticFiles();
app.UseIISPlatformHandler();
app.UseCors("OpenBookAPI");
app.UseSwagger();
app.UseSwaggerUi();
app.UseSignalR();
var hubContext = connectionManager.GetHubContext<OpenBookAPI.SignalR.Hubs.LogHub>();
app.UseJwtBearerAuthentication(options =>
{
options.Audience = Configuration["Auth:ClientId"];
options.Authority = Configuration["Auth:Domain"];
options.AuthenticationScheme = "Automatic";
options.RequireHttpsMetadata = false;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateLifetime = true
};
});
var localLogger = new LoggerConfiguration()
.WriteTo.Trace()
.WriteTo.Console().CreateLogger();
var signalRlogger = new LoggerConfiguration()
.WriteTo.Sink(new SignalRSink(hubContext, 10))
.MinimumLevel.Warning()
.CreateLogger();
var azureLogger = new LoggerConfiguration()
.WriteTo.AzureDocumentDB(new System.Uri("https://openbook.documents.azure.com:443/"), "j4Hzifc5HL6z4uNt152t6ECrI5J7peGpSJDlwfkEzn5Vs94pAxf71N3sw3iQS6YneXC0CvxA+MdQjP/GKVbo6A==")
.MinimumLevel.Warning()
.CreateLogger();
if (runtimeEnv.OperatingSystem.Equals("Windows", StringComparison.OrdinalIgnoreCase))
{
loggerFactory.AddSerilog(azureLogger);
}
if (env.IsDevelopment())
{
loggerFactory.AddSerilog(localLogger);
}
loggerFactory.AddSerilog(signalRlogger);
//should go at the end
app.UseMvc();
}
示例6: Start
public static void Start(IConnectionManager connectionManager)
{
hub = connectionManager.GetHubContext<LogsHub>();
SystemController.OnGatewayConnected += OnGatewayConnected;
SystemController.OnGatewayDisconnected += OnGatewayDisconnected;
SystemController.logs.OnGatewayLogInfo += OnLogRecord;
SystemController.logs.OnGatewayLogError += OnLogRecord;
SystemController.logs.OnGatewayMessageLog += OnLogRecord;
SystemController.logs.OnGatewayDecodedMessageLog += OnLogRecord;
SystemController.logs.OnDataBaseLogInfo += OnLogRecord;
SystemController.logs.OnDataBaseLogError += OnLogRecord;
SystemController.logs.OnNodesEngineLogInfo += OnLogRecord;
SystemController.logs.OnNodesEngineLogError += OnLogRecord;
SystemController.logs.OnNodeLogInfo += OnLogRecord;
SystemController.logs.OnNodeLogError += OnLogRecord;
SystemController.logs.OnSystemLogInfo += OnLogRecord;
SystemController.logs.OnSystemLogError += OnLogRecord;
}
示例7: StoreManagerController
public StoreManagerController(IPartsUnlimitedContext context, IConnectionManager connectionManager, IMemoryCache memoryCache)
{
_db = context;
_annoucementHub = connectionManager.GetHubContext<AnnouncementHub>();
_cache = memoryCache;
}
示例8: HomeModule
public HomeModule(ApplicationSettings settings,
IJabbrConfiguration configuration,
UploadCallbackHandler uploadHandler,
IConnectionManager connectionManager,
IJabbrRepository jabbrRepository)
{
Get["/"] = _ =>
{
if (IsAuthenticated)
{
var viewModel = new SettingsViewModel
{
GoogleAnalytics = settings.GoogleAnalytics,
Sha = configuration.DeploymentSha,
Branch = configuration.DeploymentBranch,
Time = configuration.DeploymentTime,
DebugMode = (bool)Context.Items["_debugMode"],
Version = Constants.JabbRVersion,
IsAdmin = Principal.HasClaim(JabbRClaimTypes.Admin),
ClientLanguageResources = BuildClientResources()
};
return View["index", viewModel];
}
if (Principal != null && Principal.HasPartialIdentity())
{
// If the user is partially authenticated then take them to the register page
return Response.AsRedirect("~/account/register");
}
return HttpStatusCode.Unauthorized;
};
Get["/monitor"] = _ =>
{
ClaimsPrincipal principal = Principal;
if (principal == null ||
!principal.HasClaim(JabbRClaimTypes.Admin))
{
return HttpStatusCode.Forbidden;
}
return View["monitor"];
};
Get["/status"] = _ =>
{
var model = new StatusViewModel();
// Try to send a message via SignalR
// NOTE: Ideally we'd like to actually receive a message that we send, but right now
// that would require a full client instance. SignalR 2.1.0 plans to add a feature to
// easily support this on the server.
var signalrStatus = new SystemStatus { SystemName = "SignalR messaging" };
model.Systems.Add(signalrStatus);
try
{
var hubContext = connectionManager.GetHubContext<Chat>();
var sendTask = (Task)hubContext.Clients.Client("doesn't exist").noMethodCalledThis();
sendTask.Wait();
signalrStatus.SetOK();
}
catch (Exception ex)
{
signalrStatus.SetException(ex.GetBaseException());
}
// Try to talk to database
var dbStatus = new SystemStatus { SystemName = "Database" };
model.Systems.Add(dbStatus);
try
{
var roomCount = jabbrRepository.Rooms.Count();
dbStatus.SetOK();
}
catch (Exception ex)
{
dbStatus.SetException(ex.GetBaseException());
}
// Try to talk to storage
var azureStorageStatus = new SystemStatus { SystemName = "Upload storage" };
model.Systems.Add(azureStorageStatus);
try
{
if (!String.IsNullOrEmpty(settings.AzureblobStorageConnectionString))
{
var azure = new AzureBlobStorageHandler(settings);
UploadResult result;
using (var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes("test")))
{
result = azure.UploadFile("statusCheck.txt", "text/plain", stream)
.Result;
}
//.........这里部分代码省略.........
示例9: CommunicateController
public CommunicateController(ILogger<CommunicateController> logger, IRepository repository, IConnectionManager connectionManager)
{
_logger = logger;
_repository = repository;
_comHub = connectionManager.GetHubContext<ComHub>();
}
示例10: MessageProcessor
public MessageProcessor(IConnectionManager connectionManager)
{
this.tripsHub = connectionManager.GetHubContext<TripsHub>();
}
示例11: Start
public static void Start(IConnectionManager connectionManager)
{
hub = connectionManager.GetHubContext<MySensorsHub>();
SystemController.OnGatewayConnected += OnGatewayConnected;
}
示例12: NotificationsController
public NotificationsController(
IConnectionManager connectionManager)
{
this.notificationsHub = connectionManager.GetHubContext<NotificationsHub>();
}
示例13: ChatController
/// <summary>
/// Constructor
/// </summary>
/// <param name="chatManager">the chat repository manager</param>
/// <param name="signalRConnectionManager">the SignalR connection manager</param>
/// <param name="userManager">the Identity user manager</param>
public ChatController(IChatManager<string, ChatLeUser, Conversation, Attendee, Message, NotificationConnection> chatManager, IConnectionManager signalRConnectionManager, UserManager<ChatLeUser> userManager)
{
_chatManager = chatManager;
_hub = signalRConnectionManager.GetHubContext<ChatHub>();
_userManager = userManager;
}
示例14: Start
public static async Task Start(ILoggerFactory loggerFactory, IConfigurationRoot Configuration,
IConnectionManager connectionManager)
{
if (serialControllerStarted) return;
serialControllerStarted = true;
var logger = loggerFactory.CreateLogger("RequestInfoLogger");
//configure
string portName = null;
try
{
SerialController.serialPortDebugState = Boolean.Parse(Configuration["SerialPort:DebugState"]);
SerialController.serialPortDebugTxRx = Boolean.Parse(Configuration["SerialPort:DebugTxRx"]);
SerialController.enableAutoAssignId = Boolean.Parse(Configuration["Gateway:EnableAutoAssignId"]);
SerialController.gatewayDebugState = Boolean.Parse(Configuration["Gateway:DebugState"]);
SerialController.gatewayDebugTxRx = Boolean.Parse(Configuration["Gateway:DebugTxRx"]);
SerialController.dataBaseEnabled = Boolean.Parse(Configuration["DataBase:Enable"]);
SerialController.dataBaseConnectionString = Configuration["DataBase:ConnectionString"];
SerialController.dataBaseWriteInterval = Int32.Parse(Configuration["DataBase:WriteInterval"]);
SerialController.dataBaseDebugState = Boolean.Parse(Configuration["DataBase:DebugState"]);
SerialController.dataBaseWriteTxRxMessages = Boolean.Parse(Configuration["DataBase:WriteTxRxMessages"]);
SerialController.sensorsTasksEnabled = Boolean.Parse(Configuration["SensorsTasks:Enable"]);
SerialController.sensorsTasksUpdateInterval = Int32.Parse(Configuration["SensorsTasks:UpdateInterval"]);
SerialController.sensorsLinksEnabled = Boolean.Parse(Configuration["SensorsLinks:Enable"]);
SerialController.softNodesEnabled = Boolean.Parse(Configuration["SoftNodes:Enable"]);
SerialController.softNodesPort = Int32.Parse(Configuration["SoftNodes:Port"]);
SerialController.softNodesDebugTxRx = Boolean.Parse(Configuration["SoftNodes:DebugTxRx"]);
SerialController.softNodesDebugState = Boolean.Parse(Configuration["SoftNodes:DebugState"]);
SerialController.logicalNodesEnabled = Boolean.Parse(Configuration["LogicalNodes:Enable"]);
SerialController.logicalNodesUpdateInterval = Int32.Parse(Configuration["LogicalNodes:UpdateInterval"]);
SerialController.logicalNodesDebugEngine = Boolean.Parse(Configuration["LogicalNodes:DebugEngine"]);
SerialController.logicalNodesDebugNodes = Boolean.Parse(Configuration["LogicalNodes:DebugNodes"]);
portName = Configuration["SerialPort:Name"];
}
catch
{
Log("ERROR: Bad configuration in appsettings.json file.");
throw new Exception("Bad configuration in appsettings.json file.");
}
if (portName != null)
{
SerialController.OnDebugStateMessage += Log;
SerialController.OnDebugTxRxMessage += Log;
hub = connectionManager.GetHubContext<ClientsHub>();
SerialController.gateway.OnMessageRecievedEvent += OnMessageRecievedEvent;
SerialController.gateway.OnMessageSendEvent += OnMessageSendEvent;
SerialController.gateway.OnConnectedEvent += OnConnectedEvent;
SerialController.gateway.OnDisconnectedEvent += OnDisconnectedEvent;
SerialController.gateway.OnClearNodesListEvent += OnClearNodesListEvent;
SerialController.gateway.OnNewNodeEvent += OnNewNodeEvent;
SerialController.gateway.OnNodeUpdatedEvent += OnNodeUpdatedEvent;
SerialController.gateway.OnNodeLastSeenUpdatedEvent += OnNodeLastSeenUpdatedEvent;
SerialController.gateway.OnNodeBatteryUpdatedEvent += OnNodeBatteryUpdatedEvent;
SerialController.gateway.OnSensorUpdatedEvent += OnSensorUpdatedEvent;
SerialController.gateway.OnNewSensorEvent += OnNewSensorEvent;
SerialController.logicalNodesEngine.OnNewNodeEvent += OnNewLogicalNodeEvent;
SerialController.logicalNodesEngine.OnNodeUpdatedEvent += OnLogicalNodeUpdatedEvent;
SerialController.logicalNodesEngine.OnNodeDeleteEvent += OnLogicalNodeDeleteEvent;
SerialController.logicalNodesEngine.OnLinksUpdatedEvent += OnLinksUpdatedEvent;
SerialController.logicalNodesEngine.OnLinkDeleteEvent += OnLinkDeleteEvent;
SerialController.logicalNodesEngine.OnNewLinkEvent += OnNewLinkEvent;
//start
SerialController.Start(portName);
}
}
示例15: EventController
public EventController(IConnectionManager connectionManager)
{
this.tripsHub = connectionManager.GetHubContext<TripsHub>();
}