ASP.NET Core Signalr或Signalr Java客户端是否有发送或接收空值的问题?
我正在创建多人纸牌游戏。我使用ASP.NET Core Signalr与Java编写的Android客户端进行完整的双工通信。在Android上,我使用Signalr Java客户库库。
对于某些通信,我发现只使用SignalR进行同步请求响应类型的事物是很自然的。 SignalR允许在下面进行检查。
public async Task<string> GetString(){ return "foo"; }
这是按预期的。我可以从Android调用服务器方法,并通过阻止或通过回调获得响应。
现在解决问题。我有场景,我发现可以从信号方法返回null
对象。
public async Task<GameState?> GetGameState(string gameName){
if (gameIsCanceled) return null;
else return new ProperGameState();
}
在这种情况下,我似乎返回实际游戏状态对象的情况似乎很好。但是,我返回null
的情况都没有返回。
Single<String> stringPromise = hubConnection.invoke(String.class, "GetRunningGame");
String runningGameName = stringPromise.blockingGet();
上面就像在Android中看起来像是主动。它不会通过blockingget()
有人遇到这个问题,或者知道我可能做错了什么?
I am creating a multiplayer card game. I use ASP.NET Core SignalR for full duplex communication with an Android client written in Java. On Android I use the SignalR Java client library.
For some communication I find it natural to just use signalR for synchronous request-response type of thing. SignalR allows for such as exampled below.
public async Task<string> GetString(){ return "foo"; }
This works as intended. I can invoke the server method from Android and get a response either blocking or via a callback.
Now to the problem. I have scenarios where I find it suitable to return a null
object from the SignalR method.
public async Task<GameState?> GetGameState(string gameName){
if (gameIsCanceled) return null;
else return new ProperGameState();
}
In this kind of scenario it seems like the case where I return an actual game state object works fine. But the cases in which I return null
nothing is returned.
Single<String> stringPromise = hubConnection.invoke(String.class, "GetRunningGame");
String runningGameName = stringPromise.blockingGet();
Above is like the invokation looks in Android. It does not get pass the blockingGet()
Anyone come across this or got any idea what I might be doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论