Exemple #1
0
    def on_message(self, message):
        message = json.loads(message)
        try:
            message[ID]
        except:
            raise web.HTTPError(400, "ERROR: No id.")

        if message[ACTION_FIELD] == PLAY_ACTION:
            players[message[ID]].endGame(PlayerClick(message[X], message[Y]))
        elif message[ACTION_FIELD] == RECORD_ACTION:
            db.saveRecord(message[MSG], players[message[ID]].record)
Exemple #2
0
 def on_message(self, message):
     message = json.loads(message)
     try:
         message[ID]
     except:
         raise web.HTTPError(400, "ERROR: No id.")
     if message[ACTION_FIELD] == PLAY_ACTION:
         players[message[ID]].endGame(PlayerClick(message[X], message[Y]))
     elif message[ACTION_FIELD] == RECORD_ACTION:
         db.saveRecord(message[MSG], players[message[ID]].record)
     elif message[ACTION_FIELD] == 'friend':
         if message[MSG] in players:
             if not players[message[MSG]].game:
                 Game(self.player, players[message[MSG]]).start()
             else:
                 self.write_message(msg.noFriend())
         else:
             self.write_message(msg.noFriend())
Exemple #3
0
def test():

    argsItems = request.args
    if argsItems and len(argsItems) >= 12:
        record = {
            'route_id': int(request.args.get('route_id')),
            'localtime': request.args.get('localtime'),
            'lot': int(request.args.get('lot')),
            'lat': int(request.args.get('lat')),
            'alt': float(request.args.get('alt')),
            'speed': float(request.args.get('speed')),
            'head': float(request.args.get('head')),
            'accracy': float(request.args.get('accracy')),
            'type': int(request.args.get('type')),
            'seg_index': int(request.args.get('seg_index')),
            'next_station': request.args.get('next_station'),
            'poi': request.args.get('poi')
        }

        db.saveRecord(record)

        return str(record)

    return 'Invalid param'