def post(self):
		user = users.get_current_user()
		game_key = self.request.get("game_key")
		self.channel = Channel()
		if not game_key:
			#if the client did not specify a game_key, then obviously they have no friends so we'll create a game_key for them
			game_key = str(random.getrandbits(32)) + user.user_id() # a relatively long pseudo random number should ensure enough uniqueness that we require (after all, it's not secret!)
			token = self.channel.createToken(user, game_key)

			self.game = Game(key_name = str(game_key))
			self.game.put()
			gameupdater = GameUpdater(self.game)
			gameupdater.setup()
			
			self.response.headers['Content-Type'] = 'application/json'
			self.response.write(json.dumps({'game_key': game_key, 'token' : token})) #Return a JSON with the token inside		
		else:
			game = Game.get_by_key_name(self.request.get('game_key'))
			if not game :
				self.response.headers['Content-Type'] = 'application/json'
				self.response.write(json.dumps({'error' : 'no game exists'})) #Return a JSON with the token inside
			else :
				game_key =  self.request.get('game_key')
				token = self.channel.createToken(user, game_key)
				self.response.headers['Content-Type'] = 'application/json'
				self.response.write(json.dumps({'game_key': game_key, 'token' : token})) #Return a JSON with the token inside
	def post(self):
		self.channel = Channel()
		data = self.channel.clientDisconnected(self.request.get("from"))
		#Data is a list which has the player and the game, in that order)
		if data[1] : 
			gu = GameUpdater(data[1])
			gu.leaveGame(data[0])
	def post(self):
		user = users.get_current_user()
		if not user:
			self.response.headers['Content-Type'] = 'application/json'
			self.response.write(json.dumps({'status': 'no_login'}))
			return #end the script
		game = Game.get_by_key_name(self.request.get('game_key'))
		gu = GameUpdater(game)
		gu.rollTheDice(user)
	def post(self):
		user = users.get_current_user()
		game = Game.get_by_key_name(self.request.get('game_key'))
		action = self.request.get('action')
		property = self.request.get('property')
		gu = GameUpdater(game)
		if action == 'buy' :
			gu.buyHouse(user, property)
		elif action == 'sell' :
			#gu.sellHouse(user, property)
			pass
	def post(self):
		user = users.get_current_user()
		game = Game.get_by_key_name(self.request.get('game_key'))
		gu = GameUpdater(game)
		gu.chat(user, self.request.get('message'))
	def post(self):
		user = users.get_current_user()
		game = Game.get_by_key_name(self.request.get('game_key'))
		gu = GameUpdater(game)
		gu.buyProperty(user)
	def post(self):
		#start game(game_key) iff client_id is the game creator
		game = Game.get_by_key_name(self.request.get('game_key'))
		gu = GameUpdater(game)
		gu.startGame()