在 asyncore 中,我如何向所有或部分客户端发送数据?
我正在构建一个小型 MMORPG,并且尝试使用异步而不是线程。
1)我如何将数据发送到某些客户端,因为在线程中,a将每个客户端套接字和当前内容保存在字典a中,并以其唯一的id作为键。那么我如何主观地将数据发送给所有客户端。
谢谢,如果我没有提供足够的信息,请说
I'm building a little MMORPG and im trying to use asyncore rather then threading.
1) How would i send data to certain clients, because in threading a saved each clients socket and current in a dictionary a with its unique id as a key. So how could i subjective send data to all the clients.
Thankyou, please say if i didnt give enough information
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现您希望转向异步编程而不是线程编程,因为它非常可靠并且更易于调试。
然而,
asyncore
是一个糟糕的库。我根本不建议您使用它,因为它需要大量重写才能完成简单的操作,例如读取标准 io。我建议你转向 twisted - 它是一个很棒的异步框架,经过良好的测试和开发,具有良好的 API 文档和良好的社区支持。
无论您决定使用哪个库,我都认为 Dave Peticolas 的博客文章系列有关异步编程的初学者信息的重要来源。请阅读它。
有一些游戏正在使用 Twisted 开发。一个例子是 Minions of Mirth - 我从未玩过它,但看起来很酷。
还有 divmod 的想象 - 这是模拟主义者对角色扮演、互动小说领域的看法和多人地下城。它融合了各个领域的游戏功能,同时尝试提供比现有系统通常提供的更丰富的环境。
希望我有所帮助。
I find it great that you want to move to asynchronous programming instead of threading, since it is so much reliable and easier to debug.
However,
asyncore
is a bad library to do so. I don't advise you use it at all, since it requires a significant rewrite to do simple things like read standard io.I suggest you move to twisted - it is a great asynchronous framework, well tested and developed, with good api documentation and good community support.
Regardless of your decision on which library to use, I find this series of blog posts by Dave Peticolas to be a great source of beginner information on asynchronous programming. Please read it.
There are some games under development using twisted. One example is Minions of Mirth - I never played it but it seems cool.
There's also divmod's imaginary - it's a simulationist's take on the realm of role playing, interactive fiction, and multiplayer dungeons. It incorporates gameplay features from each area while attempting to provide a richer environment than is generally available from existing systems.
Hope I helped.