#NEWLINE# def handle_message( self , data ) : #NEWLINE# #INDENT# msg_type = str ( data [ 0 ] ) #NEWLINE# handler = self . handlers . get ( msg_type ) #NEWLINE# if payload : #NEWLINE# #INDENT# ( handler , _ , _ ) = handler #NEWLINE# msg_id = ( data [ ( - 1 ) ] if ( msg_type == ':return' ) else None ) #NEWLINE# data = ( data [ 1 : ( - 1 ) ] if ( msg_type == ':return' ) else data [ 1 : ] ) #NEWLINE# payload = None #NEWLINE# if ( len ( data ) == 1 ) : #NEWLINE# #INDENT# payload = data [ 0 ] #NEWLINE# #UNINDENT# if ( len ( data ) > 1 ) : #NEWLINE# #INDENT# payload = data #NEWLINE# #UNINDENT# return handler ( msg_id , payload ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . logger . warn ( ( 'handle_message: unexpected message type: ' + msg_type ) )