From f31ed069ef6472261da49ffe32b5209c5e707b6a Mon Sep 17 00:00:00 2001 From: johan Date: Tue, 24 Sep 2013 21:26:50 +0200 Subject: [PATCH] Ignore messages which are not a reply to the request Former-commit-id: 23aeecabb9dba84d8118ee83a16a964a8163a363 --- libsrc/xbmcvideochecker/XBMCVideoChecker.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libsrc/xbmcvideochecker/XBMCVideoChecker.cpp b/libsrc/xbmcvideochecker/XBMCVideoChecker.cpp index 117fd46c..5c8718bc 100644 --- a/libsrc/xbmcvideochecker/XBMCVideoChecker.cpp +++ b/libsrc/xbmcvideochecker/XBMCVideoChecker.cpp @@ -7,7 +7,7 @@ XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, u QObject(), _address(QString::fromStdString(address)), _port(port), - _request("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":1}"), + _request("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":666}"), _timer(), _socket(), _grabVideo(grabVideo), @@ -54,6 +54,15 @@ void XBMCVideoChecker::receiveReply() // expect that the reply is received as a single message. Probably oke considering the size of the expected reply QString reply(_socket.readAll()); + std::cout << reply.toStdString() << std::endl; + + // check if the resply is a reply to one of my requests + if (!reply.contains("\"id\":666")) + { + // probably not. Leave this mreply as is and don't act on it + return; + } + GrabbingMode newMode = GRABBINGMODE_INVALID; if (reply.contains("video")) {