diff options
Diffstat (limited to 'src/Common/Requests')
-rw-r--r-- | src/Common/Requests/StatusRequest.cpp | 11 | ||||
-rw-r--r-- | src/Common/Requests/StatusRequest.h | 9 | ||||
-rw-r--r-- | src/Common/Requests/UserListRequest.cpp | 11 | ||||
-rw-r--r-- | src/Common/Requests/UserListRequest.h | 9 |
4 files changed, 22 insertions, 18 deletions
diff --git a/src/Common/Requests/StatusRequest.cpp b/src/Common/Requests/StatusRequest.cpp index dbaba23..3526e23 100644 --- a/src/Common/Requests/StatusRequest.cpp +++ b/src/Common/Requests/StatusRequest.cpp @@ -25,16 +25,19 @@ namespace Common { namespace Requests { void StatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { - connection->send(Net::Packet(Net::Packet::STATUS, requestId)); + XmlPacket packet; + packet.setType("GetStatus"); + + connection->send(packet.encode(requestId)); } -void StatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) { - if(packet.getType() != Net::Packet::OK) { +void StatusRequest::handlePacket(Net::Connection*, uint16_t, const XmlPacket &packet) { + if(packet.getType() != "OK") { finishWithError(Exception(Exception::UNEXPECTED_PACKET)); return; // TODO Logging } - finish(Net::Packets::HostStatusPacket(packet)); + finish(packet); } } diff --git a/src/Common/Requests/StatusRequest.h b/src/Common/Requests/StatusRequest.h index 5712404..e9c8a4c 100644 --- a/src/Common/Requests/StatusRequest.h +++ b/src/Common/Requests/StatusRequest.h @@ -20,20 +20,19 @@ #ifndef MAD_COMMON_REQUESTS_STATUSREQUEST_H_ #define MAD_COMMON_REQUESTS_STATUSREQUEST_H_ -#include "../Request.h" -#include <Net/Packets/HostStatusPacket.h> +#include "../XmlRequest.h" namespace Mad { namespace Common { namespace Requests { -class StatusRequest : public Request<Net::Packets::HostStatusPacket> { +class StatusRequest : public XmlRequest { protected: virtual void sendRequest(Net::Connection *connection, uint16_t requestId); - virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); + virtual void handlePacket(Net::Connection *connection, uint16_t, const XmlPacket &packet); public: - StatusRequest(slot_type slot) : Request<Net::Packets::HostStatusPacket>(slot) {} + StatusRequest(slot_type slot) : XmlRequest(slot) {} }; } diff --git a/src/Common/Requests/UserListRequest.cpp b/src/Common/Requests/UserListRequest.cpp index cd9c760..2545677 100644 --- a/src/Common/Requests/UserListRequest.cpp +++ b/src/Common/Requests/UserListRequest.cpp @@ -25,16 +25,19 @@ namespace Common { namespace Requests { void UserListRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { - connection->send(Net::Packet(Net::Packet::USERS_LIST, requestId)); + XmlPacket packet; + packet.setType("ListUsers"); + + connection->send(packet.encode(requestId)); } -void UserListRequest::handlePacket(Net::Connection*, const Net::Packet &packet) { - if(packet.getType() != Net::Packet::OK) { +void UserListRequest::handlePacket(Net::Connection*, uint16_t, const XmlPacket &packet) { + if(packet.getType() != "OK") { finishWithError(Exception(Exception::UNEXPECTED_PACKET)); return; // TODO Logging } - finish(Net::Packets::UserListPacket(packet)); + finish(packet); } } diff --git a/src/Common/Requests/UserListRequest.h b/src/Common/Requests/UserListRequest.h index c62e284..9702a42 100644 --- a/src/Common/Requests/UserListRequest.h +++ b/src/Common/Requests/UserListRequest.h @@ -20,20 +20,19 @@ #ifndef MAD_COMMON_REQUESTS_USERLISTREQUEST_H_ #define MAD_COMMON_REQUESTS_USERLISTREQUEST_H_ -#include "../Request.h" -#include <Net/Packets/UserListPacket.h> +#include "../XmlRequest.h" namespace Mad { namespace Common { namespace Requests { -class UserListRequest : public Request<Net::Packets::UserListPacket> { +class UserListRequest : public XmlRequest { protected: virtual void sendRequest(Net::Connection *connection, uint16_t requestId); - virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); + virtual void handlePacket(Net::Connection *connection, uint16_t, const XmlPacket &packet); public: - UserListRequest(slot_type slot) : Request<Net::Packets::UserListPacket>(slot) {} + UserListRequest(slot_type slot) : XmlRequest(slot) {} }; } |