Example #1
0
    def get_instance(cls, app):

        if app in Environment.channels:
            return Environment.channels[app]
        else:
            instance = App()
            instance.name = app
            Environment.channels[app] = instance
            return instance
Example #2
0
    def get_instance(cls, app):

        if app in Environment.channels:
            return Environment.channels[app]
        else:
            instance = App()
            instance.name = app
            Environment.channels[app] = instance
            return instance
Example #3
0
 def post(self, app=None):
     self.app = App.get_instance(app)
     self.set_header("Access-Control-Allow-Method", "POST, OPTIONS")
     self.set_header("Access-Control-Allow-Headers", "Content-Type")
     self.set_header("Content-Type", "application/json")
     self.finish('{"URL":"ws://%s/session/%s?%s","pingInterval":3}' %
                 (self.request.host, app, self.app.get_apps_count()))
     self.app.create_application_channel(self.request.body)
Example #4
0
 def post(self, app=None):
     self.app = App.get_instance(app)
     self.set_header("Access-Control-Allow-Method", "POST, OPTIONS")
     self.set_header("Access-Control-Allow-Headers", "Content-Type")
     self.set_header("Content-Type", "application/json")
     self.finish(
         '{"URL":"ws://%s/session/%s?%s","pingInterval":3}' % (self.request.host, app, self.app.get_apps_count())
     )
     self.app.create_application_channel(self.request.body)
Example #5
0
 def post(self, app=None):
     self.app = App.get_instance(app)
     self.set_header(
         "Access-Control-Allow-Method", "POST, OPTIONS")
     self.set_header("Access-Control-Allow-Headers", "Content-Type")
     self.set_header("Content-Type", "application/json")
     ## TODO: Use information from REGISTER packet
     ## TODO: return url based on channel property
     ## TODO: defer request until receiver connects
     self.finish(
         '{"URL":"ws://%s/session/%s?%s","pingInterval":3}' % (
         self.request.host, app, self.app.get_apps_count())
     )
Example #6
0
    def post(self, sec):
        '''Start app'''
        self.clear()
        self.set_status(201)
        self.set_header('Location', self._getLocation(self.get_name()))
        status = self.get_app_status()
        if status['browser'] is None:
            status['state'] = 'running'
            appurl = render(self.url).generate(query=self.request.body)
            status['browser'] = Browser(appurl)
            status['connectionSvcURL'] = 'http://%s/connection/%s' % (
                self.ip, self.get_name())
            status['protocols'] = self.supported_protocols
            status['app'] = App.get_instance(sec)

        self.set_app_status(status)
        self.finish()
Example #7
0
    def post(self, sec):
        '''Start app'''
        self.clear()
        self.set_status(201)
        self.set_header('Location', self._getLocation(self.get_name()))
        status = self.get_app_status()
        if status['browser'] is None:
            status['state'] = 'running'
            appurl = render(self.url).generate(query=self.request.body)
            status['browser'] = Browser(appurl)
            status['connectionSvcURL'] = 'http://%s/connection/%s' % (
                self.ip, self.get_name())
            status['protocols'] = self.supported_protocols
            status['app'] = App.get_instance(sec)

        self.set_app_status(status)
        self.finish()
Example #8
0
    def post(self, sec):
        '''Start app'''
        self.clear()
        self.set_status(201)
        self.set_header("Location", self._getLocation(self.get_name()))
        status = self.get_app_status()
        if status["pid"] is None:
            status["state"] = "running"
            status["link"] = '''<link rel="run" href="web-1"/>'''
            status["pid"] = self.launch(self.request.body)
            status["connectionSvcURL"] = "http://%s/connection/%s" % (
                self.ip, self.get_name())
            status["protocols"] = self.protocols
            status["app"] = App.get_instance(sec)

        self.set_app_status(status)
        self.finish()
Example #9
0
    def open(self, app=None):
        self.app = App.get_instance(app)
        self.cname = self.__class__.__name__

        logging.info("%s opened %s" %
                     (self.cname, self.request.uri))
Example #10
0
 def open(self, app=None):
     self.app = App.get_instance(app)
     self.app.set_control_channel(self)
     while len(self.buf) > 0:
         self.reply(self.buf.pop())
Example #11
0
 def run(self):
     # self.lock.wait(30)
     self.lock.clear()
     self.lock.wait()
     App.get_instance(
         self.name).get_control_channel().new_request(self.data)
Example #12
0
 def open(self, app=None):
     self.app = App.get_instance(app)
     self.app.set_control_channel(self)
     while len(self.buf) > 0:
         self.reply(self.buf.pop())
Example #13
0
 def run(self):
     # self.lock.wait(30)
     self.lock.clear()
     self.lock.wait()
     App.get_instance(self.name).get_control_channel().new_request(
         self.data)
Example #14
0
    def open(self, app=None):
        self.app = App.get_instance(app)
        self.cname = self.__class__.__name__

        logging.info("%s opened %s" % (self.cname, self.request.uri))