home · contact · privacy
Only include clients with sessions in send-to-all.
[plomrogue2-experiments] / new2 / plomrogue / io.py
index 9f34b180f851793b04ce02e32c52b46ea9c68481..acf58d4adf177b2e5ce779d4a58a8c5f9b4c8b00 100644 (file)
@@ -53,7 +53,7 @@ class GameIO():
 
         """
         from inspect import signature
-        from plomrogue.errors import GameError, ArgError
+        from plomrogue.errors import GameError, ArgError, PlayError
         from plomrogue.misc import quote
 
         def answer(connection_id, msg):
@@ -76,6 +76,8 @@ class GameIO():
                     #        f.write(input_ + '\n')
         except ArgError as e:
             answer(connection_id, 'ARGUMENT_ERROR ' + quote(str(e)))
+        except PlayError as e:
+            answer(connection_id, 'PLAY_ERROR ' + quote(str(e)))
         except GameError as e:
             answer(connection_id, 'GAME_ERROR ' + quote(str(e)))
 
@@ -89,5 +91,6 @@ class GameIO():
         if connection_id:
             self.server.clients[connection_id].put(msg)
         else:
-            for c in self.server.clients.values():
-                c.put(msg)
+            for c_id in self.game.sessions:
+                client = self.server.clients[c_id]
+                client.put(msg)