Beispiel #1
0
    def post(self):
        obj = json.loads(self.request.body)
        msg = Message(obj["id"],obj["action"],obj["clientId"],obj["data"])
#        channel.send_message(str(msg.userId), "in the handler"+str(msg.userId))
        if msg.action:
            if msg.action[0] == '_':
                self.error(403) # access denied
                return
            else:
                scripts.actions(msg.action,msg.data).start() 
#            msg.action="script1"
#            add_task(msg)
            
           # thread.start_new_thread(schedule,(1,))
        else:
            self.error(404) # no action specified
            
        self.response.headers["Content-Type"] = "application/jsonrequest"
        self.response.out.write(json.dumps(msg.userId))
Beispiel #2
0
    def get(self):

        obj = json.loads(self.request.get("JSONRequest"))
        msg= Message(obj["id"],obj["action"],obj["clientId"],obj["data"])
        if msg.action:
            if msg.action[0] == '_':
                self.error(403) # access denied
                return
            elif msg.action == "openChannel":
                func = getattr(RPCMethods(), "openChannel", None)
                token=func(msg.data,msg.userId)
                self.response.headers["Content-Type"] = "application/jsonrequest"
                self.response.out.write(json.dumps(token))
            else :
                scripts.actions(msg.action,msg.data).start() 
            
            """elif msg.action == "createUserInstance":
                
                user=scripts.createUserInstance(msg.data)
                dbproc.newUser(user)
                channel.send_message(str(msg.userId), "in the handler"+str(msg.data))"""
            
        else:
            self.error(404) # no action specified