示例#1
0
def relay_view(request):
    """
    Simply relays a message via the channel API to the given client
    """

    # get message details from post data
    token = request.POST['token']
    message = request.POST['message']
    # send channel message
    send_message(token, message)
    return HttpResponse('channel messages relayed')
示例#2
0
def game_relay_view(request, game_id):
    """
    Simple POST handler for relaying a message to all players in a game
    """

    game = Game.get_or_404(game_id)
    # ensure player sending message is in game
    if not request.user.user_id() in game.players:
        raise Http403
    # relay the message to everyone in the game
    send_message(game.players, request.body)
    return {'success': 'messages relayed'}
示例#3
0
def game_relay_view(request, game_id):
    """
    Simple POST handler for relaying a message to all players in a game
    """

    game = Game.get_or_404(game_id)
    # ensure player sending message is in game
    if not request.user.user_id() in game.players:
        raise Http403
    # relay the message to everyone in the game
    send_message(game.players, request.body)
    return {'success': 'messages relayed'}
示例#4
0
def relay_view(request):

    """
    Simply relays a message via the channel API to the given client
    """

    # get message details from post data
    token = request.POST['token']
    message = request.POST['message']
    # send channel message
    send_message(token, message)
    return HttpResponse('channel messages relayed')