36 lines
979 B
C#
36 lines
979 B
C#
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; }
|
|
} |