from pants import Engine, Server, Stream class Echo(Stream): def on_read(self, data): self.write(data) Server(Echo).listen(4040) Engine.instance().start()
'name': 'entity_001', 'pos': [30, 90, 15] } } entity_message = json.dumps(entity_packet) self.write(u'{}'.format(entity_message)) def on_close(self): pass def on_handshake(self, request, headers): return super(WebSocketConnection, self).on_handshake(request, headers) def on_read(self, data): print data def engine_loop(): pass def tick(): pass if __name__ == '__main__': HTTPServer(WebSocketConnection).listen(('0.0.0.0', 8080)) engine = Engine.instance() engine.loop(engine_loop) engine.cycle(6.0, tick) engine.start(0.01)