Esempio n. 1
0
 def _NH_ChatStreamGotMessage(self, notification):
     stream = notification.sender
     message = notification.data.message
     if message.content_type not in ('text/html', 'text/plain'):
         log.msg(u'Unsupported content type: %s, ignoring message' % message.content_type)
         stream.msrp_session.send_report(notification.data.chunk, 413, 'Unwanted message')
         return
     stream.msrp_session.send_report(notification.data.chunk, 200, 'OK')
     # Send MSRP chat message to other participants
     session = stream.session
     self.incoming_message_queue.send((session, 'msrp_message', message))
     # Send MSRP chat message to IRC chat room
     if message.content_type == 'text/html':
         content = html2text(message.content)
     elif message.content_type == 'text/plain':
         content = message.content
     else:
         log.warning('unexpected message type: %s' % message.content_type)
         return
     sender = message.sender
     irc_message = '%s: %s' % (format_identity(sender), content)
     if self.irc_protocol is not None:
         self.irc_protocol.send_message(irc_message.encode('utf-8'))
     else:
         self.pending_messages.append(irc_message)
Esempio n. 2
0
 def play_file_in_player(self, player, file, delay):
     player.filename = file
     player.pause_time = delay
     try:
         player.play().wait()
     except WavePlayerError, e:
         log.warning(u"Error playing file %s: %s" % (file, e))
Esempio n. 3
0
 def handle_incoming_subscription(self, subscribe_request, data):
     if subscribe_request.event != 'conference':
         subscribe_request.reject(489)
         return
     NotificationCenter().add_observer(self, sender=subscribe_request)
     self.subscriptions.append(subscribe_request)
     try:
         subscribe_request.accept()
     except SIPCoreError, e:
         log.warning('Error accepting SIP subscription: %s' % e)
         subscribe_request.end()