#NEWLINE# def _handle_message( self , opcode , data ) : #NEWLINE# #INDENT# if opcode . client_terminated : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( opcode == 1 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# decoded = data . decode ( 'utf-8' ) #NEWLINE# #UNINDENT# except UnicodeDecodeError : #NEWLINE# #INDENT# self . _abort ( ) #NEWLINE# return #NEWLINE# #UNINDENT# self . _async_callback ( self . on_message ) ( decoded ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( opcode == 2 ) : #NEWLINE# #INDENT# self . _async_callback ( self . on_message ) ( data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( opcode == 8 ) : #NEWLINE# #INDENT# self . client_terminated = True #NEWLINE# self . close ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( opcode == 9 ) : #NEWLINE# #INDENT# self . _write_frame ( True , 10 , data ) #NEWLINE# self . _async_callback ( self . on_ping ) ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( opcode == 10 ) : #NEWLINE# #INDENT# self . _async_callback ( self . on_pong ) ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _abort ( )