Python 扭曲多个客户端

发布于 2024-11-26 19:04:34 字数 293 浏览 0 评论 0原文

我试图在业余时间做一个新项目,但我很难掌握它。

我还没有用它做过任何“真正的”工作,只是让自己忙于阅读我找到的文档和网站。

假设我正在制作一款具有多个区域(地图)的多人游戏,有点像 MMORPG。 根据我的阅读,工厂似乎是一条可行的道路(每个区域一个工厂)。

所以我的问题是如何将连接从一个工厂(区域)移至另一个工厂(区域)进行处理?

也许我与这里的理论相去甚远,如果是这样,请这么说。我之前已经用低级套接字做了很多工作,但这对我来说很难掌握。

感谢您的任何答复!

/ TL

Im trying to get an hang of twisted for a new project I want to do on my spare time and Im having difficulties getting a grip of it.

I havnt done any "real" work with it yet, just keeping myself busy with reading docs and sites Ive found.

So say that I was making a multiplayer game with multiple zones (maps), kinda like and MMORPG.
From what Ive read it seems like factories are the way to go (one factory per zone).

So my question is how can I move a connection from one factory (zone) to get handled in another one?

Perhaps Im way off with the theory here and if so please say so. Ive done pretty much work with low-level sockets before but this is hard to grip for me.

Thanks for any answers!

/ TL

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

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

发布评论

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

评论(1

独行侠 2024-12-03 19:04:34

工厂是一种将创建连接的特定方式与特定侦听或连接套接字关联起来的方法。这就是你所说的“这个端口正在使用 X 协议”。

连接处理程序(Protocol 实例)构建完成后,除了 .factory 属性之外,它不会与其工厂关联。您只需更改其 .factory 属性即可指向其他对象。

然而,在 MMORPG 中,“区域”通常是应用程序级数据结构,指的是几何体、玩家等的集合。绝对没有理由将一个区域与一个工厂关联起来。事实上,如果您希望玩家在区域之间自由移动,这意味着他们在第二个区域中将继续使用与第一个区域中相同的连接,这表明 Factory 绝对是错误的关联 Twisted 数据结构与它。

从你的问题中我不清楚为什么你认为这些对象应该直接相关。如果您尝试构建一个示例程序,我希望您很快就会意识到它行不通。

Factories are a way to associate a particular way to create a connection with a particular listening or connecting socket. They are how you say "this port is speaking protocol X".

Once a connection handler (Protocol instance) is constructed, it's not associated with its factory beyond the .factory attribute. You can just change its .factory attribute to point to some other object.

However, in an MMORPG, "Zones" are typically application-level data structures which refer to collections of geometry, players, etc. There's absolutely no reason to associate one Zone per one Factory. In fact, if you want players freely moving between Zones, that implies that they're going to keep using the same connection when in the second Zone as in the first, which suggests that Factory is definitely the wrong Twisted data-structure to be associating with it.

It's not clear to me from your question why you thought that these objects should be directly related though. If you tried to construct an example program I would expect that you would quickly realize that it wouldn't work.

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