Add project files.
This commit is contained in:
36
SendPrintJob/Program.cs
Normal file
36
SendPrintJob/Program.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Reflection;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
var url = "wss://api.dev.gastrojames.ch/hubs/internal";
|
||||
var accessToken = url; // or your actual token
|
||||
|
||||
var connection = new HubConnectionBuilder()
|
||||
.WithUrl(url, options =>
|
||||
{
|
||||
options.AccessTokenProvider = () => Task.FromResult<string?>(accessToken);
|
||||
options.SkipNegotiation = true;
|
||||
options.Transports = Microsoft.AspNetCore.Http.Connections.HttpTransportType.WebSockets;
|
||||
})
|
||||
.WithAutomaticReconnect()
|
||||
.Build();
|
||||
|
||||
connection.On<PrintJob>("PrintJob", (args) =>
|
||||
{
|
||||
Console.WriteLine($"Received print job for working area: {args.WorkingAreaId}");
|
||||
|
||||
|
||||
});
|
||||
|
||||
await connection.StartAsync();
|
||||
|
||||
Console.ReadLine();
|
||||
|
||||
public class PrintJob
|
||||
{
|
||||
[JsonPropertyName("workingAreaId")]
|
||||
public string WorkingAreaId { get; set; }
|
||||
[JsonPropertyName("content")]
|
||||
public string Content { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user