Turn by Turn game: Use SignalR or both SignalR and REST API?

痞子三分冷 提交于 2019-12-10 17:27:49

问题


I'm write a turn-by-turn mobile game. Each game have 2 minutes. So every two minutes server will calculate rank and generate next game to clients. I use Asp.net to write server.
I choose SignalR to communicate between client and server. I have 2 choices for implementing games:
1) Use SignalR only to communicate with clients
2) Use SignalR to notify client, and use REST API to get or update information of game.

Could you please advice me what choice is better and please explain detail.

Thanks in advance.


回答1:


While I am not a SignalR expert, I can definitely tell you this:

Since you have chosen SignalR, use it for all the tasks it can perform.

Sending updated information about the game to the client definitely seems like a task for SignalR. Having a separate REST api is unnecessary.

Sending a message via SignalR that the state has updated, and client should make a REST call to get the updated information, is an unnecessary extra request. I would avoid it and use SignalR to send the updated information.



来源:https://stackoverflow.com/questions/11646918/turn-by-turn-game-use-signalr-or-both-signalr-and-rest-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!