Silverlight 套接字或数据库请求?

发布于 2024-07-13 12:33:04 字数 191 浏览 4 评论 0原文

我目前正在为一项任务编写一个在线回合制角色扮演游戏。 在游戏中,玩家可以互相聊天,并在完成一轮后发送他们的动作。 处理玩家之间数据交换的最佳方式是什么? 套接字或将所有信息存储在数据库中并且程序定期请求检查任何更新? 除非有更好的方法。

请注意,该游戏是大规模的,即很多玩家将在同一服务器上同时玩多个游戏,因此我必须尽可能提高效率。

I am currently coding an online turn based rpg for an assignment. In the game players can chat with each other and send their actions once they complete a turn. What is the best way to take care of the data exchange between the players. Sockets or storing all information in a database and the program periodically does requests to check for any updates? Unless there is a better approach.

Please note that the game is meant to be wide scale, i.e alot of players will be having a number of games simultaniously on the same sever, so I must try to be as efficient as possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

っ〆星空下的拥抱 2024-07-20 12:33:04

在 Silverlight 中,您只能连接回为 Silverlight 应用程序提供服务的主机,因此排除了客户端-客户端套接字。 游戏中的所有内容(包括聊天)都必须通过服务器进行。

Windows Communication Foundation (WCF) 在 Silverlight2 中使用非常好。 游戏采用回合制会让事情变得更容易一些,因为这意味着您不必实时保持玩家之间完全相同的游戏状态(即:不以最大 100 毫秒延迟为目标)。

In Silverlight, you can only connect back to the host that served the Silverlight app, so that rules out client-client sockets. Everything in your game (including chat) will have to go via a server.

Windows Communication Foundation (WCF) is quite nice to work with in Silverlight2. Having your game turn-based makes things a little bit easier because it means you dont have to maintain the exact same game-state between players in realtime (ie: not aiming for max 100ms latency).

筱武穆 2024-07-20 12:33:04

如果可能,请使用 WCF。

Use WCF if it is possible.

挽梦忆笙歌 2024-07-20 12:33:04

主要有两种可能性。 您可以应用套接字通信,也可以使用双工WCF。 以下是权衡:

套接字 => 更好的性能胜过更低的生产率
复式WCF => 性能较差,但生产力更高

对于这两种情况,网上都有一些很好的示例,但如果决定使用 WCF 解决方案,这里有一些资源:

A Peter McG 的非常好的教程
有关 来自 msdn 的双工 WCF 的信息。

There are two major possibilities. You can apply the Sockets communication or you can use the Duplex WCF. Here are the tradeoffs:

Sockets => better performance over smaller productivity
Duplex WCF => worse performance but greater productivity

There are some great examples on the net for both scenerios but if decide on the WCF solution here are some of the resources:

A very good tutorial by Peter McG.
Information about duplex WCF from msdn.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文