#NEWLINE# def _on_frame_start( self , data ) : #NEWLINE# #INDENT# ( header , payloadlen ) = struct . unpack ( 'BB' , data ) #NEWLINE# self . _final_frame = ( header & 128 ) #NEWLINE# reserved_bits = ( header & 112 ) #NEWLINE# self . _frame_opcode = ( header & 15 ) #NEWLINE# self . _frame_opcode_is_control = ( self . _frame_opcode & 8 ) #NEWLINE# if reserved_bits : #NEWLINE# #INDENT# return self . _abort ( ) #NEWLINE# #UNINDENT# if ( payloadlen & 128 ) : #NEWLINE# #INDENT# return self . _abort ( ) #NEWLINE# #UNINDENT# payloadlen = ( payloadlen & 127 ) #NEWLINE# if ( self . _frame_opcode_is_control and ( payloadlen >= 126 ) ) : #NEWLINE# #INDENT# return self . _abort ( ) #NEWLINE# #UNINDENT# if ( payloadlen < 126 ) : #NEWLINE# #INDENT# self . _frame_length = payloadlen #NEWLINE# self . stream . read_bytes ( self . _frame_length , self . _on_frame_data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( payloadlen == 126 ) : #NEWLINE# #INDENT# self . stream . read_bytes ( 2 , self . _on_frame_length_16 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( payloadlen == 127 ) : #NEWLINE# #INDENT# self . stream . read_bytes ( 8 , self . _on_frame_length_64 )