def make_hybi07_frame(buf, opcode=1):
 if (len(buf) > 65535):
  length = ('\x7f%s' % pack('>Q', len(buf)))
 elif (len(buf) > 125):
  length = ('~%s' % pack('>H', len(buf)))
 else:
  length = chr(len(buf))
 header = chr((128 | opcode))
 frame = ('%s%s%s' % (header, length, buf))
 return frame

def make_hybi07_frame ( buf , opcode = 1 ) : if ( len ( buf ) > 65535 ) : length = ( '\x7f%s' % pack ( '>Q' , len ( buf ) ) ) elif ( len ( buf ) > 125 ) : length = ( '~%s' % pack ( '>H' , len ( buf ) ) ) else : length = chr ( len ( buf ) ) header = chr ( ( 128 | opcode ) ) frame = ( '%s%s%s' % ( header , length , buf ) ) return frame
make a hybi-07 frame .