'recieve data as frame from server.'

def read_frame(self):

    header_bytes = self._read_strict(2)
    b1 = (header_bytes[0] if six.PY3 else ord(header_bytes[0]))
    fin = ((b1 >> 7) & 1)
    opcode = (b1 & 15)
    b2 = (header_bytes[1] if six.PY3 else ord(header_bytes[1]))
    mask = ((b2 >> 7) & 1)
    length = (b2 & 127)
    length_data = ''
    if (length == 126):
        length_data = self._read_strict(2)
        length = struct.unpack('!H', length_data)[0]
    elif (length == 127):
        length_data = self._read_strict(8)
        length = struct.unpack('!Q', length_data)[0]
    mask_key = ''
    if mask:
        mask_key = self._read_strict(4)
    data = self._read_strict(length)
    if mask:
        data = self.mask_or_unmask(mask_key, data)
    return (fin, opcode, data)
