轮流转的游戏:使用SignalR或两者SignalR和REST API? [英] Turn by Turn game: Use SignalR or both SignalR and REST API?

查看:249
本文介绍了轮流转的游戏:使用SignalR或两者SignalR和REST API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个转由转动的手机游戏。每场比赛有2分钟。因此,每隔两分钟服务器将计算排名,并产生下一场比赛给客户。我用Asp.net写的服务器。

我选择SignalR客户端和服务器之间的通信。我有2个选择实施游戏:

1)使用SignalR只与客户沟通

2)使用SignalR通知客户,并使用REST API来获取或更新游戏信息。



能否请你指点我怎样选择更好,请解释细节。



先谢谢了。

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.

推荐答案

虽然我不是一个SignalR专家,我可以肯定地告诉你:

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

既然你选择了SignalR,所有使用它的它可以执行的任务。

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

发送有关游戏更新的信息给客户端肯定似乎为SignalR的任务。拥有一个单独的REST API是不必要的。

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

通过SignalR发送一条消息,该州已经更新,和客户应作出REST调用来获取更新的信息,是一种不必要的额外要求。我会避免它,并使用SignalR发送更新的信息。

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.

这篇关于轮流转的游戏:使用SignalR或两者SignalR和REST API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆