Код: Выделить всё
public interface IClient
{
public struct ReportPayload
{
public string Message { get; set; }
}
Task Report(ReportPayload payload);
public struct SetImagePayload
{
public string ImageTitle { get; set; }
public byte[] Bytes { get; set; }
}
Task SetImage(SetImagePayload payload);
}
Код: Выделить всё
hub.Clients.All.Report(new IClient.ReportPayload {Message = "foo"});
hub.Clients.All.SetImage(new IClient.SetImagePayload
{
ImageTitle = "aaaaaaaa",
Bytes = bytes
});
Код: Выделить всё
Report()Код: Выделить всё
SetImage()Код: Выделить всё
SetImage()Мой клиент:
Код: Выделить всё
Connection = new HubConnectionBuilder()
.WithUrl($"http:localhost:1234/api")
.WithAutomaticReconnect()
.Build();
Connection.On(nameof(IClient.Report), payload =>
{
Console.WriteLine($"Server has reported: {payload.Message}");
});
Connection.On(nameof(IClient.SetImage), payload =>
{
Console.WriteLine($"SetImage got the message: {payload.Bytes.Length}");
});
Я не получаю никаких ошибок, и это странно
Подробнее здесь: https://stackoverflow.com/questions/764 ... send-bytes