log.error(u'Error dispatching composing indication to %s: %s' % (s.remote_identity.uri, e))
except StopIteration:
# This session doesn't have a chat stream, send him a SIP MESSAGE
if ConferenceConfig.enable_sip_message:
body = IsComposingMessage(state=State(data.state), refresh=Refresh(data.refresh), last_active=LastActive(data.last_active or datetime.now()), content_type=ContentType('text')).toxml()
user_count = len(set(str(s.remote_identity.uri) for s in self.sessions if any(stream for stream in s.streams if stream.type == 'audio')) - set([str(session.remote_identity.uri)]))
log.msg(u'%s started conference %s %s' % (format_identity(session.remote_identity), self.uri, format_stream_types(session.streams)))
else:
log.msg(u'%s joined conference %s %s' % (format_identity(session.remote_identity), self.uri, format_stream_types(session.streams)))
if str(session.remote_identity.uri) not in set(str(s.remote_identity.uri) for s in self.sessions if s is not session):
self.dispatch_server_message('%s has joined the room %s' % (format_identity(session.remote_identity), format_stream_types(session.streams)), exclude=session)
def remove_session(self, session):
notification_center = NotificationCenter()
try:
chat_stream = (stream for stream in session.streams or [] if stream.type == 'chat').next()
# Take the first session which doesn't have a chat stream. This is needed because the
# seession picked up here will later be ignored. It doesn't matter if we ignore a session
# without a chat stream, because that means we will send SIP MESSAGE, and it will fork, so
# everyone will get it.
session = (session for session in self.sessions if str(session.remote_identity.uri) == str(from_header.uri) and any(stream for stream in session.streams if stream.type != 'chat')).next()
except StopIteration:
# MESSAGE from a user which is not in this room
message_request.answer(503)
return
if content_type == 'message/cpim':
try:
message = CPIMMessage.parse(data.body)
except CPIMParserError:
message_request.answer(500)
return
else:
body = message.body
content_type = message.content_type
sender = message.sender or format_identity(from_header, cpim_format=True)
if message.timestamp is not None and isinstance(message.timestamp, Timestamp):