Hi everyone. I'm writing a Twisted based daemon for a simple text-based multiplayer game. The game logic goes like this. The client sends a string in a particular format (command.arguments (also separated by period)) to the server. The server receives that string, split it, and run the command along with the arguments. I already made it working.
Some of the commands called (login for example) has to get data from database. I'm using Twistar to make things fancy. Here's where I found some difficulties. The function which calls the available commands returns the result of the called command. The problem is that I don't know how to make my login function to return the result of the query.
Simply, what I want : send strings (or list, or number, or whatever) gained from the database to the client.
What I get now : the server sends a deferred object or an empty string or list (I've tried some ways to send things to the client).
I know it sounds so newbie, but this is my first Twisted program, and I'm still learning, so please spare me.
Well, I think the scripts will make things clearer:
There's no complicated logic yet. I started writing this thing just three days ago.
The deferred does fire. It prints the "bla bla bla logged in" properly.
The client is just a simple client which sends 'login.Sky Warden.123'. The arguments will be separated by the '.' as well.
I think that's all. Maybe it's just me who don't fully understand deferreds, or it's just a logic hole. Or maybe both. XD
Thank you everyone.