Пример #1
0
    def send_message(self, room_name, sender, body):
        """ Send a message to a room!
        """
        destinations = yield self.get_servers_for_context(room_name)

        try:
            yield self.replication_layer.send_pdu(
                Pdu.create_new(
                    context=room_name,
                    pdu_type="sy.room.message",
                    content={"sender": sender, "body": body},
                    origin=self.server_name,
                    destinations=destinations,
                )
            )
        except Exception as e:
            logger.exception(e)
Пример #2
0
    def invite_to_room(self, room_name, sender, invitee):
        """Invite someone to a room!"""
        self._on_invite(self.server_name, room_name, invitee)

        destinations = yield self.get_servers_for_context(room_name)

        try:
            yield self.replication_layer.send_pdu(
                Pdu.create_new(
                    context=room_name,
                    is_state=True,
                    pdu_type="sy.room.member",
                    state_key=invitee,
                    content={"membership": "invite"},
                    origin=self.server_name,
                    destinations=destinations,
                ))
        except Exception as e:
            logger.exception(e)
Пример #3
0
    def join_room(self, room_name, sender, joinee):
        """Join a room!"""
        self._on_join(room_name, joinee)

        destinations = yield self.get_servers_for_context(room_name)

        try:
            pdu = Pdu.create_new(
                context=room_name,
                pdu_type="sy.room.member",
                is_state=True,
                state_key=joinee,
                content={"membership": "join"},
                origin=self.server_name,
                destinations=destinations,
            )
            yield self.replication_layer.send_pdu(pdu)
        except Exception as e:
            logger.exception(e)
Пример #4
0
    def join_room(self, room_name, sender, joinee):
        """ Join a room!
        """
        self._on_join(room_name, joinee)

        destinations = yield self.get_servers_for_context(room_name)

        try:
            pdu = Pdu.create_new(
                    context=room_name,
                    pdu_type="sy.room.member",
                    is_state=True,
                    state_key=joinee,
                    content={"membership": "join"},
                    origin=self.server_name,
                    destinations=destinations,
                )
            yield self.replication_layer.send_pdu(pdu)
        except Exception as e:
            logger.exception(e)
Пример #5
0
    def invite_to_room(self, room_name, sender, invitee):
        """ Invite someone to a room!
        """
        self._on_invite(self.server_name, room_name, invitee)

        destinations = yield self.get_servers_for_context(room_name)

        try:
            yield self.replication_layer.send_pdu(
                Pdu.create_new(
                    context=room_name,
                    is_state=True,
                    pdu_type="sy.room.member",
                    state_key=invitee,
                    content={"membership": "invite"},
                    origin=self.server_name,
                    destinations=destinations,
                )
            )
        except Exception as e:
            logger.exception(e)