'Send ws messages to GPMDP and verify request id in response.'

def send_gpmdp_msg(self, namespace, method, with_id=True):

    from websocket import _exceptions
    try:
        websocket = self.get_ws()
        if (websocket is None):
            self._status = STATE_OFF
            return
        self._request_id += 1
        websocket.send(json.dumps({'namespace': namespace, 'method': method, 'requestID': self._request_id}))
        if (not with_id):
            return
        while True:
            msg = json.loads(websocket.recv())
            if ('requestID' in msg):
                if (msg['requestID'] == self._request_id):
                    return msg
    except (ConnectionRefusedError, ConnectionResetError, _exceptions.WebSocketTimeoutException, _exceptions.WebSocketProtocolException, _exceptions.WebSocketPayloadException, _exceptions.WebSocketConnectionClosedException):
        self._ws = None
