コード例 #1
0
ファイル: iSpyServer.py プロジェクト: clholgat/iSpy
 def post(self, gameid):
     user = auth()
     if user == None:
         self.response.out.write(json.dumps({'error': 'No autheticated user'}))
         return
     gameid = int(gameid)
     text = self.request.get("text")
     bitmap = self.request.get("image")
     message = MyMessage()
     message.time = datetime.datetime.now()
     message.user = user
     message.gameid = gameid
     message.img = bitmap
     message.text = text
     message.confirmed = False
     message.put()
     self.response.out.write(json.dumps({'success': 'sent message'}))
コード例 #2
0
ファイル: iSpyServer.py プロジェクト: clholgat/iSpy
    def post(self):
        logging.debug("CreateGame: ")
        user = auth()
        if user == None:
            logging.debug("CreateGame: Entered unauthenticated user!!")
            self.response.out.write(json.dumps({'error': 'Unauthenticated User'}))
            return

        #sendMessage(user, "HELLO");
        logging.debug("CreateGame: Before creating Game Object")
        #Create Game
        game = Game()
        game.name = self.request.get("name")
        game.players = []
        game.messages = []
        game.creator = user.key().id()
        game.location = user.location
        game.range = float(self.request.get('range'))
        game.startTime = datetime.datetime.now()
        logging.debug("CreateGame: Before creating Clue Object")
        
        clue = MyMessage()
        clue.text = self.request.get('clue')
        clue.time = datetime.datetime.now() 
        clue.put()
        logging.debug("CreateGame: Clue Object Created")
        game.clue = clue.key().id()
        game.active = True
        game.put()
        logging.debug("Game object created")
        clue.gameid = game.key().id()
        clue.user = user
        clue.put()
        user.activeGame = game
        user.put()
        #Notify users in the location
        #Return Game ID to UI
        logging.debug(game.key().id())
        self.response.out.write(json.dumps({'gameid': game.key().id()}))