Пример #1
0
    def connect_to_app(self, app_name, url = None):
        self.login()

        if url is None:
            self.app_name = app_name
            
            url_response = self.s.get(server_url + '/app-url?app-name=' + app_name)
            url = url_response.json()['objects']['url']
            self.app_url = url
        else:
            self.app_url = url
        
        auth_info = self.s.get(url + '/login').json()

        response = self.server_post(server_url + '/oauth/authorize', data=auth_info['objects'])
        response = response.json()

        self.app_auth_token = response['objects']['auth_token']
        
        self.app_post(url + '/register-device-id', 
                    data = {'device_id': self.device['id']})
        
        #hack since i actually dont know how to just get a cookie
        cookie = None
        for session_cookie in self.s.cookies:
            if session_cookie.domain != self.server_domain:
                cookie = session_cookie

        o = urlparse(self.app_url)
        socketIO = SocketIO(o.hostname, o.port, 
                            params={'t': long(time.time() * 1000)}, 
                            cookies={"session": str(cookie.value)})
        app_namespace = socketIO.define(client.AppNamespace, '/client')
        app_namespace.login = self
        return socketIO, app_namespace
Пример #2
0
    def connect_to_server(self):
        socketIO = SocketIO(server_url,
                            params={'t': long(time.time() * 1000)},
                            cookies={"session": str(self.server_session_id)})
        server_namespace = socketIO.define(client.ServerNamespace, '/client')
        #really wish i could do this in the constructor
        server_namespace.login = self

        return socketIO, server_namespace
Пример #3
0
 def connect_to_server(self):
     socketIO = SocketIO(server_url, 
                         params={'t': long(time.time() * 1000)}, 
                         cookies={"session": str(self.server_session_id)})
     server_namespace = socketIO.define(client.ServerNamespace, '/client')
     #really wish i could do this in the constructor
     server_namespace.login = self
         
     return socketIO, server_namespace
Пример #4
0
    def connect_to_app(self, app_name, url=None):
        self.login()

        if url is None:
            self.app_name = app_name

            url_response = self.s.get(server_url + '/app-url?app-name=' +
                                      app_name)
            url = url_response.json()['objects']['url']
            self.app_url = url
        else:
            self.app_url = url

        auth_info = self.s.get(url + '/login').json()

        response = self.server_post(server_url + '/oauth/authorize',
                                    data=auth_info['objects'])
        response = response.json()

        self.app_auth_token = response['objects']['auth_token']

        self.app_post(url + '/register-device-id',
                      data={'device_id': self.device['id']})

        #hack since i actually dont know how to just get a cookie
        cookie = None
        for session_cookie in self.s.cookies:
            if session_cookie.domain != self.server_domain:
                cookie = session_cookie

        o = urlparse(self.app_url)
        socketIO = SocketIO(o.hostname,
                            o.port,
                            params={'t': long(time.time() * 1000)},
                            cookies={"session": str(cookie.value)})
        app_namespace = socketIO.define(client.AppNamespace, '/client')
        app_namespace.login = self
        return socketIO, app_namespace