Untitled
unknown
plain_text
2 years ago
1.1 kB
3
Indexable
using System; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR.Client; namespace SignalRConsoleListener { class Program { static async Task Main(string[] args) { Console.WriteLine("SignalR Console Listener"); string apiAddress = "http://192.168.1.101:9000"; // Adres Twojego API string printerMACAddress = "00:1B:44:11:3A:B7"; // Adres MAC drukarki var hubConnection = new HubConnectionBuilder() .WithUrl(apiAddress + $"/signalRHub?MAC={printerMACAddress}") .Build(); hubConnection.On<string>("ReceiveToken", token => { Console.WriteLine("Received token: " + token); }); await hubConnection.StartAsync(); Console.WriteLine("SignalR connection started. Listening for events..."); Console.ReadLine(); await hubConnection.StopAsync(); await hubConnection.DisposeAsync(); } } }