简体   繁体   中英

Send a json object to .net server using signalr and Java client

I am using SignalR 5.0, I am trying to send a JSON from the Android client. I have looked into this . But it's not working for me, the send works I get the json in the test "{"Id":"123123","ReceviedDateTime":"Nov 23, 2020 12:50:55 PM","RepliedDatetime":"Nov 23, 2020 12:50:55 PM"}" but the Pong method is never called. Added services.AddSignalR().AddJsonProtocol(); in the startup

Pong model:

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; }
}

Java code: 在此处输入图片说明

Methods (.net core 5)

    public void Pong(PongModel pongModel)
    {
    }

    public void Send(string test)
    {
    }

Pass object directly example without serializing: hubConnection.send("Pong", p); Add this to get the binding error: "Microsoft.AspNetCore.SignalR": "Debug", "Microsoft.AspNetCore.Http.Connections": "Debug"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM