2018-04-10 23:35:16 +00:00
|
|
|
#pragma once
|
2018-04-11 00:13:37 +00:00
|
|
|
#include "Session.h"
|
|
|
|
#include "../dml/MessageManager.h"
|
2018-04-10 23:35:16 +00:00
|
|
|
|
|
|
|
namespace ki
|
|
|
|
{
|
|
|
|
namespace protocol
|
|
|
|
{
|
2018-04-11 00:16:21 +00:00
|
|
|
namespace net
|
2018-04-10 23:35:16 +00:00
|
|
|
{
|
2018-04-20 16:22:51 +00:00
|
|
|
enum class InvalidDMLMessageErrorCode
|
|
|
|
{
|
2018-04-22 16:11:12 +00:00
|
|
|
NONE,
|
|
|
|
UNKNOWN,
|
|
|
|
INVALID_HEADER_DATA,
|
2018-04-20 16:22:51 +00:00
|
|
|
INVALID_MESSAGE_DATA,
|
2018-04-22 16:11:12 +00:00
|
|
|
INVALID_SERVICE,
|
|
|
|
INVALID_MESSAGE_TYPE,
|
2018-04-20 16:22:51 +00:00
|
|
|
INSUFFICIENT_ACCESS
|
|
|
|
};
|
|
|
|
|
2018-04-15 21:52:13 +00:00
|
|
|
/**
|
|
|
|
* Implements an application protocol that uses the DML
|
|
|
|
* message system (as seen in Wizard101 and Pirate101).
|
|
|
|
*/
|
|
|
|
class DMLSession : public virtual Session
|
2018-04-10 23:35:16 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-04-15 21:52:13 +00:00
|
|
|
DMLSession(uint16_t id, const dml::MessageManager &manager);
|
|
|
|
virtual ~DMLSession() = default;
|
2018-04-11 00:18:31 +00:00
|
|
|
|
2018-04-20 16:12:31 +00:00
|
|
|
const dml::MessageManager &get_manager() const;
|
|
|
|
|
2018-04-11 00:18:31 +00:00
|
|
|
void send_message(const dml::Message &message);
|
2018-04-10 23:35:16 +00:00
|
|
|
protected:
|
2018-04-11 00:16:21 +00:00
|
|
|
void on_application_message(const PacketHeader& header) override;
|
2018-04-20 17:57:05 +00:00
|
|
|
virtual void on_message(const dml::Message *message) {}
|
2018-04-20 16:22:51 +00:00
|
|
|
virtual void on_invalid_message(InvalidDMLMessageErrorCode error) {}
|
2018-04-10 23:35:16 +00:00
|
|
|
private:
|
2018-04-11 00:16:21 +00:00
|
|
|
const dml::MessageManager &m_manager;
|
2018-04-10 23:35:16 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2018-04-15 21:52:13 +00:00
|
|
|
}
|