Wyślij obiekt json do serwera .net za pomocą Signalr i klienta Java
Nov 24 2020
Używam SignalR 5.0, próbuję wysłać JSON z klienta systemu Android. Przyjrzałem się temu . Ale to nie działa dla mnie, wysyłanie działa. Otrzymuję plik json w teście „{" Id ":" 123123 "," ReceviedDateTime ":" 23 listopada 2020 12:50:55 "," RepliedDatetime ":" Lis 23, 2020 12:50:55 "}", ale metoda Pong nigdy nie jest wywoływana. Usługi dodane.AddSignalR (). AddJsonProtocol (); w starcie
Model Ponga:
public class PongModel
{
public int Id { get; set; }
public int DeviceId { get; set; }
public string PhoneNumber { get; set; }
public DateTime SendDatetime { get; set; }
public DateTime ReceviedDateTime { get; set; }
public DateTime RepliedDatetime { get; set; }
}
Kod Java:

Metody (.net core 5)
public void Pong(PongModel pongModel)
{
}
public void Send(string test)
{
}
Odpowiedzi
Zulander Nov 24 2020 at 03:25
Przekaż obiekt bezpośrednio przykład bez serializacji: hubConnection.send ("Pong", p); Dodaj to, aby uzyskać błąd wiązania: „Microsoft.AspNetCore.SignalR”: „Debugowanie”, „Microsoft.AspNetCore.Http.Connections”: „Debugowanie”