'Read and return a message from the stream. If `None` is returned, then
the socket is considered closed/errored.'

def receive(self):

    if self.closed:
        self.current_app.on_close(MSG_ALREADY_CLOSED)
        raise WebSocketError(MSG_ALREADY_CLOSED)
    try:
        return self.read_message()
    except UnicodeError:
        self.close(1007)
    except ProtocolError:
        self.close(1002)
    except socket.timeout:
        self.close()
        self.current_app.on_close(MSG_CLOSED)
    except socket.error:
        self.close()
        self.current_app.on_close(MSG_CLOSED)
    return None
