Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 375
janoliver Avatar asked Nov 25 '25 02:11

janoliver


1 Answers

It seems like Pyro is exactly what I need.

like image 168
janoliver Avatar answered Nov 26 '25 18:11

janoliver