public static async Task Main(string[] args) { Console.WriteLine(deviceConnectionString); DeviceClient.DeviceClient deviceClient = DeviceClient .DeviceClient .CreateFromConnectionString(deviceConnectionString, mqttTransport); ServiceClient serviceClient = ServiceClient.CreateFromConnectionString(hubConnectionString); HubHelper hubHelper = new HubHelper(serviceClient, deviceId); DeviceHelper deviceHelper = new DeviceHelper(deviceClient); // deviceHelper.ReceiveCommands(); hubHelper.ReceiveFeedback(); await deviceHelper.SendEvent(); // await hubHelper.SendMessageToDevice(); Task.Delay(10000).Wait(); //if I block this thread then will the others continue? Console.WriteLine("All done"); }
public async IAsyncEnumerable <bool> UserEdit(AppUserVM appUserVM) { yield return(await HubHelper.WrapAsync(_logger, async() => { var user = await _userManager.FindByIdAsync(appUserVM.Id); if (user == default) { throw new HubException("User does not exist"); } HubHelper.Validate(appUserVM); var nameClaim = (await _userManager.GetClaimsAsync(user)) .FirstOrDefault(m => m.Type == JwtClaimTypes.Name); if (nameClaim == null || appUserVM.Name != nameClaim.Value) { var newNameClaim = new Claim(JwtClaimTypes.Name, appUserVM.Name); if (nameClaim == null) { await _userManager.AddClaimAsync(user, newNameClaim); } else { await _userManager.ReplaceClaimAsync(user, nameClaim, newNameClaim); } } return true; }));
public async IAsyncEnumerable <ListResponse <AppUserVM> > UserList( AppUserFilter filter, AppUserSort sort, Paginate paginate) { yield return(await HubHelper.WrapAsync(_logger, async() => { IQueryable <AppUser> query = _db.Users .Include(m => m.UserClaims) .Include(m => m.UserRoles) .ThenInclude(m => m.Role); switch (sort) { case AppUserSort.EmailAsc: query = query.OrderBy(m => m.Email); break; case AppUserSort.EmailDesc: query = query.OrderByDescending(m => m.Email); break; } if (!string.IsNullOrEmpty(filter.Email)) { query = query.Where(m => EF.Functions.ILike(m.Email, $"%{filter.Email}%")); } return await PaginationHelper.FromQueryAsync <AppUser, AppUserVM>(paginate, query); })); }
/// <summary> /// Initializes a new instance of the <see cref="ItemHub"/> class with the supplied ApplicationManager. /// </summary> public ItemHub() { // if hubManager is null, create a new instance. this ensures that there is only one copy for the hub regardless of the // number of instances. if (hubManager == default(HubHelper)) { hubManager = new HubHelper(manager, this); } }
/// <summary> /// Initializes a new instance of the <see cref="LogHub"/> class with the supplied ApplicationManager. /// </summary> public LogHub() { // if hubManager is null, create a new instance. this ensures that there is only one copy for the hub regardless of the // number of instances. if (hubManager == default(HubHelper)) { hubManager = new HubHelper(manager, this); RealtimeLogger.LogAppended += hubManager.OnChange; } }
static FlightsController() { if (_airportManager == null) { _airportManager = new AirportManager(); } if (_hubHelper == null) { _hubHelper = new HubHelper(_airportManager); } }
private static TypesModel GenerateTypeScriptModel(TypeScriptGeneratorOptions options) { var signalrHelper = new HubHelper(options); return(new TypesModel( options.ReferencePaths ?? new string[0], signalrHelper.GetHubs(), signalrHelper.GetServiceContracts(), signalrHelper.GetClients(), signalrHelper.GetDataContracts(), signalrHelper.GetEnums())); }
public override async Task RunJobAsync() { try { await LogInformation("Contacting Github now to see if new version is available."); var update = _updateService.CheckForUpdate(Settings); await LogProgress(20); if (update.IsUpdateAvailable && Settings.AutoUpdate) { await LogInformation($"New version found: v{update.AvailableVersion}"); await LogInformation($"Auto update is enabled so going to update the server now!"); await _settingsService.SetUpdateInProgressSettingAsync(true); await HubHelper.BroadcastUpdateState(true); Task.WaitAll(_updateService.DownloadZipAsync(update)); await LogProgress(50); await _updateService.UpdateServerAsync(); await _settingsService.SetUpdateInProgressSettingAsync(false); await HubHelper.BroadcastUpdateFinished(true); } else if (update.IsUpdateAvailable) { await LogInformation($"New version found: v{update.AvailableVersion}"); await LogInformation("Auto updater is disabled, so going to end the job now."); } else { await LogInformation("No new version available"); } } catch (Exception) { await _settingsService.SetUpdateInProgressSettingAsync(false); await HubHelper.BroadcastUpdateState(false); await HubHelper.BroadcastUpdateFinished(false); throw; } }
static HubService() { hubHelper = new HubHelper(); hubConnection = new HubConnectionBuilder() .WithUrl(ConfigurationManager.AppSettings["hostAddress"] + "riddleshub") .Build(); hubConnection.StartAsync(); hubConnection.ServerTimeout = TimeSpan.FromMinutes(10); hubConnection.On <string>("Recieve", (message) => { Console.WriteLine("User connected"); }); hubConnection.On <string, string, string>("SendInvite", (userName, levelName, message) => { hubHelper.SendInvite(userName, levelName, message); }); hubConnection.On <bool>("AcceptInvite", (accept) => { formAcceptInvite.AcceptInvite(accept); }); hubConnection.On <int>("StartGame", (gameSessionId) => { hubHelper.StartGame(gameSessionId); }); hubConnection.On <string>("Surrender", (userName) => { hubHelper.Surrender(userName); }); hubConnection.On("RivalFinished", () => { hubHelper.RivalFinished(); }); hubConnection.On("RivalExitedGame", () => { hubHelper.RivalExitedGame(); }); }
public override async Task RunJobAsync() { var result = _mediaServerService.PingMediaServer(Settings.MediaServer.FullMediaServerAddress); await LogProgress(50); if (result) { await LogInformation("We found your MediaServer server"); _mediaServerService.ResetMissedPings(); } else { await LogInformation("We could not ping your MediaServer server. Might be because it's turned off or dns is wrong"); _mediaServerService.IncreaseMissedPings(); } var status = _mediaServerService.GetMediaServerStatus(); await HubHelper.BroadcastEmbyConnectionStatus(status.MissedPings); }
public override Task OnConnected() { HubHelper.AddConn(Context.ConnectionId); UpdateUserCount(); return(base.OnConnected()); }
public void UpdateUserCount() { Clients.All.updateUserCount(HubHelper.GetCount()); }
public void GetUserCount() { Clients.Client(Context.ConnectionId).updateUserCount(HubHelper.GetCount()); }
public override Task OnDisconnected(bool stopCalled) { HubHelper.RemoveConn(Context.ConnectionId); UpdateUserCount(); return(base.OnDisconnected(stopCalled)); }