12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections.Generic;
- using Fleck;
- using FingerprintScanner;
- class Program
- {
- static void Main()
- {
- var allSockets = new List<IWebSocketConnection>();
- var server = new WebSocketServer("ws://0.0.0.0:5000");
- // Start WebSocket server
- server.Start(socket =>
- {
- socket.OnOpen = () =>
- {
- Console.WriteLine("Client connected!");
- allSockets.Add(socket);
- };
- socket.OnClose = () =>
- {
- Console.WriteLine("Client disconnected!");
- allSockets.Remove(socket);
- };
- socket.OnMessage = message =>
- {
- Console.WriteLine("Received: " + message);
- // You can handle incoming messages here if needed
- };
- socket.OnError = error =>
- {
- Console.WriteLine("Error: " + error.Message);
- };
- });
- var fingerprintManager = new FingerprintCaptureManager();
- // Subscribe to fingerprint captured event and broadcast to all clients
- fingerprintManager.OnFingerprintCaptured += (jsonData) =>
- {
- Console.WriteLine("Broadcasting fingerprint data...");
- foreach (var socket in allSockets)
- {
- socket.Send(jsonData);
- }
- };
- // Pass the targetVid string here. Replace with your actual VID if known.
- fingerprintManager.Start();
- Console.WriteLine("Fingerprint WebSocket server running on ws://0.0.0.0:5000/");
- Console.WriteLine("Press Enter to stop...");
- Console.ReadLine();
- fingerprintManager.Stop();
- }
- }
|