Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualSky Warden

Posted 25 May 2013 - 01:09 AM

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) to the server. The server receives that string, split it, and run the command along with the arguments. I already made it working.

 

One of the command called has to get data from database. I'm using Twistar to make things fancy.  The problem is, I need to return the result of the deferred made by the query. I know it sounds so newbie, but this is my first Twisted program, and I'm still learning.

 

Well, I think the scripts will make things clearer:

 

The server.py (don't worry, it's inside a code tag):

Spoiler

 

The protocols.py

 

Spoiler

 

The services.py

Spoiler

 

I'm sure the error is in the login function. I think it's like saying "Wait. My result isn't here yet" by returning a deferred, but it will be the deferred which is sent to the client.

 

Well, there's no complicated logic yet. I started writing this just two days ago. All I want is to send the query_result.username to the client. The query is fine. I can print that thingy on the server.

 

What I want : the login() function returns the result of the query (a list, string or whatever) so I can send it to the client.

What I get : the login() function returns a deferred object.

 

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. smile.png


#8Sky Warden

Posted 23 May 2013 - 07:02 AM

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) to the server. The server receives that string, split it, and run the command along with the arguments. I already made it working.

 

One of the command called has to get data from database. I'm using Twistar to make things fancy.  The problem is, I need to return the result of the deferred made by the query. I know it sounds so newbie, but this is my first Twisted program, and I'm still learning.

 

Well, I think the scripts will make things clearer:

 

The server.py (don't worry, it's inside a code tag):

Spoiler

 

The protocols.py

 

Spoiler

 

The services.py

Spoiler

 

I'm sure the error is in the login function. I think it's like saying "Wait. My result isn't here yet" by returning a deferred, but it will be the deferred which is sent to the client.

 

Well, there's no complicated logic yet. I started writing this just two days ago. All I want is to send the query_result.username to the client. The query is fine. I can print that thingy on the server.

 

What I want : the login() function returns the result of the query (a list, string or whatever).

What I get : the login() function returns a deferred object.

 

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. smile.png


#7Sky Warden

Posted 23 May 2013 - 06:52 AM

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) to the server. The server receives that string, split it, and run the command along with the arguments. I already made it working.

 

One of the command called has to get data from database. I'm using Twistar to make things fancy.  The problem is, I need to return the result of the deferred made by the query. I know it sounds so newbie, but this is my first Twisted program, and I'm still learning.

 

Well, I think the scripts will make things clearer:

 

The server.py (don't worry, it's inside a code tag):

Spoiler

 

The protocols.py

 

Spoiler

 

The services.py

Spoiler

 

I'm sure the error is in the login function. I think it's like saying "Wait. My result isn't here yet" by returning a deferred, but it will be the deferred which is sent to the client.

 

Well, there's no complicated logic yet. I started writing this just two days ago. All I want is to send the query_result.username to the client. The query is fine. I can print that thingy on the server.

 

What I want : the login() function returns the result of the query.

What I get : the login() function returns a deferred object.

 

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. smile.png


#6Sky Warden

Posted 22 May 2013 - 08:12 PM

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) to the server. The server receives that string, split it, and run the command along with the arguments. I already made it working.

 

One of the command called has to get data from database. I'm using Twistar to make things fancy.  The problem is, I need to return the result of the deferred made by the query. I know it sounds so newbie, but this is my first Twisted program, and I'm still learning.

 

Well, I think the scripts will make things clearer:

 

The server.py (don't worry, it's inside a code tag):

Spoiler

 

The protocols.py

 

Spoiler

 

The services.py

Spoiler

 

I'm sure the error is in the login function. I think it's like saying "Wait. My result isn't here yet" by returning a deferred, but it will be the deferred which is sent to the client.

 

Well, there's no complicated logic yet. I started writing this just two days ago. All I want is to send the query_result.username to the client. The query is fine. I can print that thingy on the server.

 

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. smile.png


#5Sky Warden

Posted 22 May 2013 - 08:10 PM

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) to the server. The server receives that string, split it, and run the command along with the arguments. I already made it working.

 

One of the command called has to get data from database. I'm using Twistar to make things fancy.  The problem is, I need to return the result of the deferred made by the query. I know it sounds so newbie, but this is my first Twisted program, and I'm still learning.

 

Well, I think the scripts will make things clearer:

 

The server.py (don't worry, it's inside a code tag):

Spoiler

 

The protocols.py

 

Spoiler

 

The services.py

Spoiler

 

I'm sure the error is in the login function. I think it's like saying "Wait. My result isn't here yet" by returning a deferred, but it will be the deferred which is sent to the client.

 

Well, there's no complicated logic yet. I started writing this just two days ago. All I want is to send the query_result.username to the client. The query is fine. I can print that thingy on the server.

 

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. smile.png


#4Sky Warden

Posted 22 May 2013 - 08:10 PM

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) to the server. The server receives that string, split it, and run the command along with the arguments. I already made it working.

 

One of the command called has to get data from database. I'm using Twistar to make things fancy.  The problem is, I need to return the result of the deferred made by the query. I know it sounds so newbie, but this is my first Twisted program, and I'm still learning.

 

Well, I think the scripts will make things clearer:

 

The server.py (don't worry, it's inside a code tag):

Spoiler

 

The protocols.py

 

Spoiler

 

The services.py

Spoiler

 

I'm sure the error is in the login function. I think it's like saying "Wait. My result isn't here yet" by returning a deferred, but it will be the deferred which is sent to the client.

 

Well, there's no complicated logic yet. I started writing this just two days ago. All I want is to send the query_result.username to the client. The query is fine. I can print that thingy on the server.

 

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. smile.png


PARTNERS