Ignore messages which are not a reply to the request

Former-commit-id: 23aeecabb9dba84d8118ee83a16a964a8163a363
This commit is contained in:
johan 2013-09-24 21:26:50 +02:00
parent b1b6de7ce6
commit f31ed069ef

View File

@ -7,7 +7,7 @@ XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, u
QObject(), QObject(),
_address(QString::fromStdString(address)), _address(QString::fromStdString(address)),
_port(port), _port(port),
_request("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":1}"), _request("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":666}"),
_timer(), _timer(),
_socket(), _socket(),
_grabVideo(grabVideo), _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 // expect that the reply is received as a single message. Probably oke considering the size of the expected reply
QString reply(_socket.readAll()); 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; GrabbingMode newMode = GRABBINGMODE_INVALID;
if (reply.contains("video")) if (reply.contains("video"))
{ {