与WCF实时通信 [英] Real-time communication with WCF

查看:23
本文介绍了与WCF实时通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与 wcf 建立实时通信的最佳方式是什么?IE.对于游戏,我需要一种方法,当远程用户按下键盘上的左箭头键时,服务器中的对象会相应移动.

What's the best way to create a real-time communication with wcf? I.e. for games, I need a way that when a remote user press the left arrow key on his keyboard, an object in the server moves accordingly.

我想我应该使用 WCF,这是正确的选择吗?

I think I should use WCF, is that the right option?

谢谢!

推荐答案

我认为将 WCF 用于游戏编程并不是一个好主意.使用 WCF 的最快方法可能是将 NET TCP 与单向消息一起使用,但您仍然有相当多的开销.

I don't think it's a good idea to use WCF for games programming. The fastest way with WCF would probably be using NET TCP with one-way messages, but you still have quite a bit of overhead.

我建议您考虑直接使用 UDP 对套接字进行编程,或者查看为您执行此操作的 C# 库,例如 Lidgren:http://code.google.com/p/lidgren-network

I'd suggest that you consider programming the sockets directly using UDP or look into a C# lib that does it for you, like lidgren: http://code.google.com/p/lidgren-network

这里有一些不错的初学者教程,但它们是用 C/C++ 编写的,但它们显示了当您想为游戏编写网络代码时需要考虑的事项:http://www.gamedev.net/reference/list.asp?categoryid=30

Here are some nice beginner tutorials but they are in C/C++ but they show what you need to consider when you want to write networking code for games: http://www.gamedev.net/reference/list.asp?categoryid=30

否则看看如何使用 XNA 完成网络连接.这是一个网络示例:http://creators.xna.com/en-us/sample/networkp2p

Otherwise have a look at how networking is done with XNA. Here is a networking example: http://creators.xna.com/en-us/sample/networkp2p

这实际上取决于您想将其用于哪种游戏.FPS 的要求与策略游戏的要求非常不同.

It really depends on what kind of game you want to use it for. Requirements for a FPS are very different to the requirements for a strategy game.

这篇关于与WCF实时通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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