'Send a frame over the websocket with message as its payload'

def send_frame(self, message, opcode):

    if self.closed:
        self.current_app.on_close(MSG_ALREADY_CLOSED)
        raise WebSocketError(MSG_ALREADY_CLOSED)
    if (not message):
        return
    if (opcode in (self.OPCODE_TEXT, self.OPCODE_PING)):
        message = self._encode_bytes(message)
    elif (opcode == self.OPCODE_BINARY):
        message = bytes(message)
    header = Header.encode_header(True, opcode, '', len(message), 0)
    try:
        self.raw_write((header + message))
    except socket.error:
        raise WebSocketError(MSG_SOCKET_DEAD)
    except:
        raise
