[Twisted-Python] the right twisted base classes for my project

elguavas elguavas at gmail.com
Sun Dec 18 18:05:19 MST 2016


hi all. i have a project with a networked aspect that i'm thinking of 
rewriting to use twisted. i'd like to ask for any input on the best 
twisted functions to base my rewrite on for my usage case, thanks.

the project is a fairly simple "games room" that lets a small number of 
users (from 2 up to a handful, lets say 12 max) join to play simple 2d 
board games against each other. there is also a general chat among 
current players function.

i originally wrote the networking code for this using python's stdlib 
asyncore and asynchat modules, implementing a basic rpc-like mechanism 
to allow clients and server to communicate via simple structured string 
"messages".

i have to say if it was a only bit of a nightmare to code, it was a 
_lot_ of a nightmare to test and debug... anyway, so i'm rewriting the 
networking code and looking at twisted and i'd like to make sure i start 
off using the right parts of twisted for the job right from the beginning.

the networking is based on having a server, that maintains central game 
state and coordinates it among the clients, and clients that connect to 
the sever to participate in games.

the clients need to be able to call functions on the server. the server 
needs to be able to return data to the clients and also to call 
functions back on specific clients, or subsets of clients, or all clients.

i've had a good look through the twisted docs and i'm thinking that 
perspective broker is what probably i need, likely along with its avatar 
functionality.

is this a sensible way to go or am i overlooking something obvious?

(oh, and a last questionlet would be: if that would be the right parts 
of twisted to use, what would that buy me above the other possibility 
i'm considering, which is rewiriting using python's new asyncio stuff?)

tia for any replies,
stephen.



More information about the Twisted-Python mailing list