Esempio n. 1
0
    def serve(self):
        def run_server(server):
            tornado.ioloop.IOLoop.instance().start()

        self.server = SocketServer(self.app)
        th = Thread(target=run_server, args=(self.server, ))
        th.start()
Esempio n. 2
0
    def __init__(self, uri, port):
        # Creating a Tornadio2 server for the connection
        MyRouter = tornadio2.TornadioRouter(MyConnection)

        application = Application(MyRouter.urls, socket_io_port=port)
        self.http_server = SocketServer(application,
                                        auto_start=False,
                                        xheaders=True)
Esempio n. 3
0
    def serve(self):
        def run_server(server):
            tornado.ioloop.IOLoop.instance().start()

        self.server = SocketServer(self.app)
        th = Thread(target=run_server, args=(self.server,))
        th.start()
Esempio n. 4
0
class WebSocketsServer:

    def __init__(self, uri, port):

        MyRouter = tornadio2.TornadioRouter(MyConnection)

        application = Application(MyRouter.urls, socket_io_port = port)
        self.http_server = SocketServer(application, auto_start = False)

    def start(self):
        io_loop = tornado.ioloop.IOLoop.instance()
        io_loop.start()

    def stop(self):
        self.http_server.stop()
        tornado.ioloop.IOLoop.instance().stop()
Esempio n. 5
0
class WebSocketsServer:

    def __init__(self, uri, port):
        # Creating a Tornadio2 server for the connection
        MyRouter = tornadio2.TornadioRouter(MyConnection)

        application = Application(MyRouter.urls, socket_io_port = port)
        self.http_server = SocketServer(application, auto_start = False, xheaders=True)

    # Start Tornadio2 server
    def start(self):
        io_loop = tornado.ioloop.IOLoop.instance()
        io_loop.start()

    # Stop Tornadio2 server
    def stop(self):
        self.http_server.stop()
        tornado.ioloop.IOLoop.instance().stop()
Esempio n. 6
0
class WebSocketsServer:
    def __init__(self, uri, port):
        # Creating a Tornadio2 server for the connection
        MyRouter = tornadio2.TornadioRouter(MyConnection)

        application = Application(MyRouter.urls, socket_io_port=port)
        self.http_server = SocketServer(application,
                                        auto_start=False,
                                        xheaders=True)

    # Start Tornadio2 server
    def start(self):
        io_loop = tornado.ioloop.IOLoop.instance()
        io_loop.start()

    # Stop Tornadio2 server
    def stop(self):
        self.http_server.stop()
        tornado.ioloop.IOLoop.instance().stop()
Esempio n. 7
0
class ReportServer(object):
    def __init__(self, cacher):
        router = TornadioRouter(Client)
        self.server = None
        self.cacher = cacher
        self.reportUUID = uuid.uuid4().hex
        self.app = tornado.web.Application(
            router.apply_routes([
                (r"/", MainHandler,
                 dict(template='index.jade',
                      reportUUID=self.reportUUID,
                      cacher=cacher)),
                (r"/offline\.html", MainHandler,
                 dict(template='offline.jade',
                      reportUUID=self.reportUUID,
                      cacher=cacher)),
                (r"/brief\.html$", MainHandler,
                 dict(template='brief.jade',
                      reportUUID=self.reportUUID,
                      cacher=cacher)),
                (r"/monitoring\.html$", MainHandler,
                 dict(template='monitoring.jade',
                      reportUUID=self.reportUUID,
                      cacher=cacher)),
                (r"/data\.json$", JsonHandler,
                 dict(reportUUID=self.reportUUID, cacher=cacher)),
            ]),
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            debug=True,
        )

    def serve(self):
        def run_server(server):
            tornado.ioloop.IOLoop.instance().start()

        self.server = SocketServer(self.app)
        th = Thread(target=run_server, args=(self.server, ))
        th.start()

    def stop(self):
        if (self.server):
            self.server.stop()

    def send(self, data):
        for connection in Client.CONNECTIONS:
            data['uuid'] = self.reportUUID
            connection.send(json.dumps(data))

    def reload(self):
        for connection in Client.CONNECTIONS:
            connection.emit('reload')

    def render_offline(self):
        loader = template.Loader(
            os.path.join(os.path.dirname(__file__), "templates"))
        cached_data = {
            'data': self.cacher.get_all_data(),
            'uuid': self.reportUUID,
        }
        return loader.load('offline.jade').generate(
            cached_data=json.dumps(cached_data))
Esempio n. 8
0
class ReportServer(object):

    def __init__(self, cacher):
        router = TornadioRouter(Client)
        self.server = None
        self.cacher = cacher
        self.reportUUID = uuid.uuid4().hex
        self.app = tornado.web.Application(
            router.apply_routes([
                (r"/", MainHandler, dict(
                    template='index.jade',
                    reportUUID=self.reportUUID,
                    cacher=cacher)),
                (r"/offline\.html", MainHandler, dict(
                    template='offline.jade',
                    reportUUID=self.reportUUID,
                    cacher=cacher)),
                (r"/brief\.html$", MainHandler, dict(
                    template='brief.jade',
                    reportUUID=self.reportUUID,
                    cacher=cacher)),
                (r"/monitoring\.html$", MainHandler, dict(
                    template='monitoring.jade',
                    reportUUID=self.reportUUID,
                    cacher=cacher)),
                (r"/data\.json$", JsonHandler,
                    dict(reportUUID=self.reportUUID, cacher=cacher)),
            ]),
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            debug=True,
        )

    def serve(self):
        def run_server(server):
            tornado.ioloop.IOLoop.instance().start()

        self.server = SocketServer(self.app)
        th = Thread(target=run_server, args=(self.server,))
        th.start()

    def stop(self):
        if (self.server):
            self.server.stop()

    def send(self, data):
        for connection in Client.CONNECTIONS:
            data['uuid'] = self.reportUUID
            connection.send(json.dumps(data))

    def reload(self):
        for connection in Client.CONNECTIONS:
            connection.emit('reload')

    def render_offline(self):
        loader = template.Loader(
            os.path.join(os.path.dirname(__file__), "templates"))
        cached_data = {
            'data': self.cacher.get_all_data(),
            'uuid': self.reportUUID,
        }
        return loader.load('offline.jade').generate(
            cached_data=json.dumps(cached_data))
Esempio n. 9
0
    def __init__(self, uri, port):

        MyRouter = tornadio2.TornadioRouter(MyConnection)

        application = Application(MyRouter.urls, socket_io_port = port)
        self.http_server = SocketServer(application, auto_start = False)
Esempio n. 10
0
    def __init__(self, uri, port):
        # Creating a Tornadio2 server for the connection
        MyRouter = tornadio2.TornadioRouter(MyConnection)

        application = Application(MyRouter.urls, socket_io_port = port)
        self.http_server = SocketServer(application, auto_start = False, xheaders=True)