Beispiel #1
0
    def joinRoom(self, message):
        self.rooms.add_to_room(self, message['data'])
        message_out = self.generate_message(action='roomAccept', data='')
        self.send_message(message_out)

        room_id = self.rooms.get_room_id(self)
        user = BaseHandler.get_current_user(self)
        self.broadcast(self.generate_message('countUser', self.rooms.count_user_already_in_room_of(room_id)))

        clients_name = self.rooms.get_room_clients_name(room_id)
        message_out = self.generate_message('getMember', clients_name)
        self.broadcast(message_out)
Beispiel #2
0
    def initClient(self):
        room_id = self.rooms.get_room_id(self)
        user = BaseHandler.get_current_user(self)

        if not self.rooms.checks_user_already_in_room_of(room_id, user["name"]):
            self.rooms.add_user(room_id, user["name"])
            self.chat.set_nickname(room_id, user["name"])

        nickname = self.chat.get_nickname(room_id, user["name"])

        self.send_message(self.generate_message('initCards', self.cards.get_all(room_id)))
        self.send_message(self.generate_message('chatMessages', {'cache': self.chat.cache[room_id], 'name': nickname}))
Beispiel #3
0
    def vote_up(self, message):
        message_id = message['data']['id']
        thumb_up_count = message['data']['thumb-up-count']
        user = User.get(BaseHandler.get_current_user_id(self))
        idea = Idea.get_from_cardID(card_id=message_id)
        if idea not in user.ideas:
            user.ideas.append(idea)
            user.save()

            message_out = self.generate_message('voteUp', {'id': message_id, 'thumb-up-count': thumb_up_count + 1})
            self.broadcast(message_out)
            room_id = self.rooms.get_room_id(self)
            self.cards.update_vote_count(room_id, card_id=message_id)
Beispiel #4
0
    def joinRoom(self, message):
        self.rooms.add_to_room(self, message['data'])
        message_out = self.generate_message(action='roomAccept', data='')
        self.send_message(message_out)

        room_id = self.rooms.get_room_id(self)
        user = BaseHandler.get_current_user(self)
        self.broadcast(
            self.generate_message(
                'countUser',
                self.rooms.count_user_already_in_room_of(room_id)))

        clients_name = self.rooms.get_room_clients_name(room_id)
        message_out = self.generate_message('getMember', clients_name)
        self.broadcast(message_out)
Beispiel #5
0
    def vote_up(self, message):
        message_id = message['data']['id']
        user = User.get(BaseHandler.get_current_user_id(self))
        idea = Idea.get_from_cardID(card_id=message_id)

        if idea not in user.ideas:
            user.ideas.append(idea)
            user.save()

            message_out = self.generate_message('voteUp', {'id': message_id})
            self.broadcast_to_room(self, message_out)
            room_id = self.rooms.get_room_id(self)
            self.cards.update_vote_count(room_id, card_id=message_id)
        else:
            message_out = self.generate_message('voteDown', {'id': message_id})
            self.send_message(message_out)
Beispiel #6
0
    def vote_up(self, message):
        message_id = message['data']['id']
        user = User.get(BaseHandler.get_current_user_id(self))
        idea = Idea.get_from_cardID(card_id=message_id)

        if idea not in user.ideas:
            user.ideas.append(idea)
            user.save()

            message_out = self.generate_message('voteUp', {'id': message_id})
            self.broadcast_to_room(self, message_out)
            room_id = self.rooms.get_room_id(self)
            self.cards.update_vote_count(room_id, card_id=message_id)
        else:
            message_out = self.generate_message('voteDown', {'id': message_id})
            self.send_message(message_out)
Beispiel #7
0
    def vote_up(self, message):
        message_id = message['data']['id']
        thumb_up_count = message['data']['thumb-up-count']
        user = User.get(BaseHandler.get_current_user_id(self))
        idea = Idea.get_from_cardID(card_id=message_id)
        if idea not in user.ideas:
            user.ideas.append(idea)
            user.save()

            message_out = self.generate_message(
                'voteUp', {
                    'id': message_id,
                    'thumb-up-count': thumb_up_count + 1
                })
            self.broadcast(message_out)
            room_id = self.rooms.get_room_id(self)
            self.cards.update_vote_count(room_id, card_id=message_id)
Beispiel #8
0
    def initClient(self):
        room_id = self.rooms.get_room_id(self)
        user = BaseHandler.get_current_user(self)

        if not self.rooms.checks_user_already_in_room_of(
                room_id, user["name"]):
            self.rooms.add_user(room_id, user["name"])
            self.chat.set_nickname(room_id, user["name"])

        nickname = self.chat.get_nickname(room_id, user["name"])

        self.send_message(
            self.generate_message('initCards', self.cards.get_all(room_id)))
        self.send_message(
            self.generate_message('chatMessages', {
                'cache': self.chat.cache[room_id],
                'name': nickname
            }))