janoliver
janoliver

Reputation: 7824

How can I have a shared object between sockets in gevent's Socket io module

I am trying to implement sockets using the client library of socket.io and the server implementation for Python, gevent-socketio. I got the server to run and the sockets to work. However, I am trying to implement some simple in-browser game (that I didn't write!) and the game happens completely within one instance of the game class. It works something like this:

game = Game([player1,player2])
game.turn(player1, action_one)
game.turn(player2, action_two)
...
print game.winner()

Since I want to use sockets for the turns, I need some way to share the game object on the server side between the different sockets (players). How could I do this? I really would not like to store each state of the game on the disk or in some database. Is there any other option?

Upvotes: 3

Views: 754

Answers (2)

arilou
arilou

Reputation: 475

It's not cleare what's your plroblem in. If you processs different socket's io in the same process (probably, in different greenletes), it's not a problem to share any data between different socket handlers. Could you describe your problem with more details?

Upvotes: 0

janoliver
janoliver

Reputation: 7824

It seems like Pyro is exactly what I need.

Upvotes: 1

Related Questions