iPhone应用程序的多人服务器,使用设备作为套接字服务器
我正在开发一款多人 iPhone 应用程序,最多允许 6 个用户“实时”连接和玩游戏。我一直在研究托管和非托管套接字服务器(SmartFox、ElectroServer, 光子/中子、ProjectDarkstar),我想知道是否有人对服务或实施有任何建议?任何人都知道 Zynga 的 Live Poker 这样的游戏使用什么来实现此类功能,或者您可能需要什么样的硬件?
一些子问题:
游戏是回合制的。使用 AMF 并轮询服务器是否更有意义,或者我应该选择基于套接字的路由?我目前关心的是并发连接限制和托管成本。
是否可以将设备“广播”为套接字服务器?即,一旦我连接了所有播放器,我可以将 6 个设备之一分配为套接字服务器并通过该设备推送所有通信吗?那会很疯狂吗?这将解决并发问题,我只需要依赖套接字服务器服务作为初始连接的大厅。分配的用户将保持连接以促进游戏与服务器的通信。
I'm working on a multiplayer iPhone application that allows up to 6 users to connect and play in "real time." I've been looking at hosted and non-hosted socket servers (SmartFox, ElectroServer, Photon/Neutron, ProjectDarkstar) and I'm wondering if anyone has any recommendations for services or implementation? Anyone have any idea of what a game like Zynga's Live Poker uses for this type of functionality or what kind of hardware you might need?
Some sub-questions:
The game is turn-based. Would it make more sense to use AMF and poll a server or should I go for the socket-based route? My current concern is concurrent connection limits and hosting costs.
Is it possible to "broadcast" a device as a socket server? i.e. once I get all my players connected, could I allocate one of the 6 devices to be a socket server and push all communication through that device? Would that be crazy? That would get around concurrency issues and I'd only need to rely on the socket server service as a lobby for the initial connection. The allocated user would stay connected to facilitate game to server communication.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1.
使用轮询要容易得多,而且由于游戏是回合制的,您可以以相对较慢的速度(可能几秒钟)进行轮询,这意味着电池消耗更少。也就是说,使用套接字或持久 HTTP 连接将是一种更灵活的方法(并且需要做更多的工作)。这两个问题可能会引起兴趣:
如何创建不由轮询驱动的聊天服务器?
iPhone 上的 COMET(服务器推送到客户端)
我不知道你为什么要使用 AMF。为什么不是 JSON?或者也许HessianKit?
2.
将其中一台设备指定为服务器非常有意义。拥有一个需要同步的完全去中心化的游戏客户端网络是一项非常艰巨的任务。同样,由于您的游戏是回合制的,不需要完美的实时同步,因此您不必担心集中状态会引入更多延迟。
如果您打算让用户通过本地网络玩游戏,您应该考虑使用 GameKit。
1.
It's much easier to use polling, and since the game is turn based you could poll at a relatively slow rate (perhaps a couple of seconds), which means less battery drain. That said, using sockets or persistent HTTP connections would be a slicker way of doing it (and much more work). These two questions might be of interest:
How do I create a chat server that is not driven by polling?
COMET (server push to client) on iPhone
I don't know why you would use AMF. Why not JSON? Or maybe HessianKit?
2.
It makes a lot of sense to designate one of the devices as a server. Having a completely decentralized network of game clients that need to synchronize is a very hard task. Again, since your game is turn based, which doesn't require perfect real-time synchronization, you don't have to worry that having centralized state will introduce more latency.
If you intend for users to play over a local network, you should consider using GameKit.