I've created a web server using Twisted to handle requests for a "real time" game. The server loops at 60hz on a separated Thread and updates all the clients.
Setup:
- Twisted 16.6.0
- Debian 64 bits
- Python 2.7.12
The problem is when no messages are sent from the clients, the sever starts to respond every 1 second instead of 60 times per second affecting all clients. As soon as at least one client starts to send messages (such as mouse position at 60hz) everything works fine. That happens even with only one client is connected.
I've tested both reactors select()
and poll
but no luck.
That's how the reactor gets started:
if __name__ == "__main__":
log.startLogging(sys.stdout)
factory = AppGameFactory(u"ws://127.0.0.1:8080")
factory.protocol = AppGameServerProtocol
resource = WebSocketResource(factory)
# websockets resource on "/ws" path
root.putChild(u"ws", resource)
site = Site(root)
reactor.listenTCP(8080, site)
reactor.run()
Any ideias? Am I missing anything?