laneya

multiplayer roguelike game
git clone https://git.ce9e.org/laneya.git

commit
30df63e6dca37e01cc852a012086236068d6836d
parent
44a58353f3c44f2f7fafc755c9b112ba9f58ce06
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2014-10-05 10:04
sever mainloop

Diffstat

M laneya/server.py 16 +++++++++++++++-

1 files changed, 15 insertions, 1 deletions


diff --git a/laneya/server.py b/laneya/server.py

@@ -3,6 +3,7 @@ import sys
    3     3 from twisted.python import log
    4     4 from twisted.internet.endpoints import TCP4ServerEndpoint
    5     5 from twisted.internet import reactor
   -1     6 from twisted.internet import task
    6     7 
    7     8 import protocol
    8     9 
@@ -17,10 +18,23 @@ class ServerProtocol(protocol.ServerProtocol):
   17    18             return {}
   18    19 
   19    20 
   -1    21 class Server(protocol.ServerProtocolFactory):
   -1    22     def __init__(self):
   -1    23         protocol.ServerProtocolFactory.__init__(self, ServerProtocol)
   -1    24 
   -1    25     def mainloop(self):
   -1    26         self.broadcastUpdate('echo', foo='mainloop')
   -1    27 
   -1    28 
   20    29 def main():
   21    30     log.startLogging(sys.stdout)
   -1    31     server = Server()
   22    32     endpoint = TCP4ServerEndpoint(reactor, 5001)
   23    -1     endpoint.listen(protocol.ServerProtocolFactory(ServerProtocol))
   -1    33     endpoint.listen(server)
   -1    34 
   -1    35     mainloop = task.LoopingCall(server.mainloop)
   -1    36     mainloop.start(0.1)
   -1    37 
   24    38     reactor.run()
   25    39 
   26    40