Example #1
0
        def callback(data):
            try:
                # Validate the participant against the DB.
                received_id = headers['User-ID']
                conga_id = self.db.get(
                    "SELECT conga_id FROM conga_congamember WHERE id=%s",
                    (received_id, ))[0][0]

                # At this stage we've successfully validated this participant.
                # Bring them up.
                self.participant_id = int(received_id)
                self.conga_id = conga_id
                self.state = UP

                # Join the conga.
                conga = conga_from_id(conga_id)
                conga.join(self, self.participant_id)
            except (KeyError, IndexError), e:
                # This will catch a missing User-ID as well as a failed SQL
                # lookup.
                logging.error(
                    "Hit exception %s adding participant %s to conga %s." %
                    (e, self.participant_id, conga_id))

                self.source_stream.close()
                self.state = CLOSING
Example #2
0
        def callback(data):
            try:
                # Validate the participant against the DB.
                received_id = headers['User-ID']
                conga_id = self.db.get(
                    "SELECT conga_id FROM conga_congamember WHERE id=%s",
                    (received_id,)
                )[0][0]

                # At this stage we've successfully validated this participant.
                # Bring them up.
                self.participant_id = int(received_id)
                self.conga_id = conga_id
                self.state = UP

                # Join the conga.
                conga = conga_from_id(conga_id)
                conga.join(self, self.participant_id)
            except (KeyError, IndexError), e:
                # This will catch a missing User-ID as well as a failed SQL
                # lookup.
                logging.error(
                    "Hit exception %s adding participant %s to conga %s." %
                    (e, self.participant_id, conga_id)
                )

                self.source_stream.close()
                self.state = CLOSING
Example #3
0
        def callback(data):
            # Before we start, check whether there is a Message ID on this
            # message. If there isn't, we've never seen it before.
            # Check whether this is a message we've seen before.
            conga = conga_from_id(self.conga_id)

            try:
                msg_id = headers['Message-ID']
                new_header_data = header_data
            except KeyError:
                # New message. Get a message ID for it, and then add it to the
                # header data.
                msg_id = conga.new_message(self.participant_id)
                new_header_data = header_data[:-2]
                new_header_data += 'Message-ID: %s\r\n\r\n' % (msg_id)

            dest_id = 0

            try:
                dest_id = self.destination.participant_id
                self.destination.write(new_header_data + data, msg_id, conga)
            except StreamClosedError:
                if self.destination.state != CLOSING:
                    # Unexpected closure. BYE logic has already been run by
                    # the decorator on write, so log and move on with our
                    # lives.
                    logging.error(
                        "Unexpected close by participant %d" % dest_id
                    )
Example #4
0
 def callback(data):
     # Begin by dumping ourselves out of the conga, so that we don't
     # receive any more messages. If this fails, log the failure but
     # keep going.
     try:
         conga = conga_from_id(self.conga_id)
         conga.leave(self, self.participant_id)
     except LeaveError, e:
         logging.error(
             "Failed to remove %s from conga %s because of %s" %
             (self.participant_id, self.conga_id, e))
Example #5
0
 def callback(data):
     # Begin by dumping ourselves out of the conga, so that we don't
     # receive any more messages. If this fails, log the failure but
     # keep going.
     try:
         conga = conga_from_id(self.conga_id)
         conga.leave(self, self.participant_id)
     except LeaveError, e:
         logging.error(
             "Failed to remove %s from conga %s because of %s" %
             (self.participant_id, self.conga_id, e)
         )