public async Task <SignalRServerResponse> Join(JoinGroupRequest request) { if (request.IsDetector) { await AddToDetectorGroup(); } else { await AddToConsumerGroup(request.IsHDMIController); } // Here we are selecting all the IDs that are currently in the ClientID - GroupName hash and putting them in a list IReadOnlyList <string> joinedClients = _clientIDGroupNameHash.Select(cg => cg.Key) .Where(id => id != Context.ConnectionId) .ToList(); // build the counts of each group ClientGroupStats otherGroupStats = BuildClientGroupStatsResponse(); // this one contains the group that was just joined ClientGroupStats senderGroupStats = BuildClientGroupStatsResponse(true); // publish to all clients that have joined a group that there are new group stats. await Clients.Clients(joinedClients).SendAsync(nameof(ClientGroupStats), otherGroupStats); await Clients.Caller.SendAsync(nameof(ClientGroupStats), senderGroupStats); return(new SignalRServerResponse() { Success = true }); }
static async Task Main(string[] args) { _faceDetectionConfiguration = new FaceDetectionConfiguration() { ScaleFactor = 1.2, MinimumNeighbors = 5, MinimumFaceWidth = 20, MinimumFaceHeight = 20, FaceTimeoutInSeconds = 5 }; Console.WriteLine("Hello World!"); CancellationTokenSource cts = new CancellationTokenSource(); Console.CancelKeyPress += (sender, a) => { a.Cancel = true; cts.Cancel(); }; string configurationFilePath; if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { configurationFilePath = @"/share/JAVS.Hypnos.Pi.Detector/PiSettings.json"; } else { configurationFilePath = @"./PiSettings.json"; } _piSettings = await JSONFile.LoadAsync <PiSettings>(configurationFilePath); FaceDetectionService faceDetectionService = new FaceDetectionService(_piSettings); await faceDetectionService.Init(); faceDetectionService.ListenFor <ClientGroupStats>((stats) => { foreach (var group in stats.ConnectedClientGroupCounts) { Console.WriteLine($"{group.Key}: {group.Value} Clients Connected."); _clientGroupStats = stats; } }); faceDetectionService.ListenFor <FaceDetectionConfiguration>((config) => { _faceDetectionConfiguration = config; }); await faceDetectionService.Join(new JoinGroupRequest() { IsDetector = true, Password = "******" }); RunFacialDetection(cts, faceDetectionService); }