I'm currently working on a ASP.NET Core 2 application using SignalR Core. I was wondering if it is possible to receive a complex object within the Hub class instead of a simple string or simple data structure.
Works - This example works fine: string message
public class MyHub : Hub
{
public Task SendMessage(string message)
{
// ... some logic
}
}
Works - This example works fine as well: List<Dictionary<string, object>> message
public class MyHub : Hub
{
public Task SendMessage(List<Dictionary<string, object>> message)
{
// ... some logic
}
}
Doesn't work correctly - It seems I cannot transfer complex objects via SignalR e.g. if I create a custom message class:
public class Message
{
public int MessageId { get; set; }
public List<Dictionary<string, object>> Items { get; set; }
public List<string> TextMessages { get; set; }
}
public class MyHub : Hub
{
public Task SendMessage(Message message)
{
// ... some logic
}
}
Do you know how to transfer complex objects via a SignalR RPC?
Thank you!
SendMessage
acceptsMessage
parameter? As long as you are sending in right JSON, it should go through. – Elect