开发者

Python Twisted multiple clients

开发者 https://www.devze.com 2023-03-24 01:12 出处:网络
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.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号