#NEWLINE# def _encode_msg( self , msg_code , data = None ) : #NEWLINE# #INDENT# if ( data is None ) : #NEWLINE# #INDENT# return struct . pack ( '!iB' , 1 , msg_code ) #NEWLINE# #UNINDENT# hdr = struct . pack ( '!iB' , ( 1 + len ( data ) ) , msg_code ) #NEWLINE# return ( hdr + data )