#NEWLINE# def on_new_event( self , stream_key , new_token , users = [ ] , rooms = [ ] , extra_streams = set ( ) ) : #NEWLINE# #INDENT# ' Used to inform listeners that something has happend event wise.\n\n        Will wake up all listeners for the given users and rooms.\n        ' #NEWLINE# with PreserveLoggingContext ( ) : #NEWLINE# #INDENT# user_streams = set ( ) #NEWLINE# for user in users : #NEWLINE# #INDENT# user_stream = self . user_to_user_stream . get ( str ( user ) ) #NEWLINE# if ( user_stream is not None ) : #NEWLINE# #INDENT# user_streams . add ( user_stream ) #NEWLINE# #UNINDENT# #UNINDENT# for room in rooms : #NEWLINE# #INDENT# user_streams |= self . room_to_user_streams . get ( room , set ( ) ) #NEWLINE# #UNINDENT# time_now_ms = self . clock . time_msec ( ) #NEWLINE# for user_stream in user_streams : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# user_stream . notify ( stream_key , new_token , time_now_ms ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# logger . exception ( 'Failed to notify listener' ) #NEWLINE# #UNINDENT# #UNINDENT# self . notify_replication ( )