m_userinfo const *Packet_v1_UserInfo::getUserInfo() const { assert(getRequestId() == USERINFO_GETINFO_RESPONSE_OK); m_userinfo const * unserialized = unserialize(reinterpret_cast<char const *>(getData(PROTOV1_USERINFO_START_OF_DATA, PROTOV1_USERINFO_DATA_USERINFO))); return unserialized; }
void Packet_v1_UserInfo::setAvatar(char const *avatar) { assert(getRequestId() == USERINFO_GETAVATAR_RESPONSE_OK); appendData(PROTOV1_USERINFO_START_OF_DATA, PROTOV1_USERINFO_DATA_AVATAR, reinterpret_cast<byte_t const *>(avatar)); }
void Packet_v1_UserInfo::setUserInfo(m_userinfo const *userinfo) { assert(getRequestId() == USERINFO_GETINFO_RESPONSE_OK); char const * serialized = serialize(userinfo); appendData(PROTOV1_USERINFO_START_OF_DATA, PROTOV1_USERINFO_DATA_USERINFO, reinterpret_cast<byte_t const *>(serialized)); }
void Packet_v1::Print_v1(std::string const & componentName, Manager const * manager) const { Print_base(); std::cout << "[COMPONENTID: " << componentName << " {" << PROTOV1_COMPONENTID_SIZE << "}]" << "[REQUESTID: "; COLOR_REVERSE_START; std::cout << manager->getRegisteredRequestName(getComponentId(), getRequestId()); std::cout << " {" << PROTOV1_REQUESTID_SIZE << "}]" << "[SESSIONID: " << getSessionId() << " {" << PROTOV1_SESSIONID_SIZE << "}]" << std::endl; }
EnviJSONRPC::EnviJSONRPC(var data, const bool isRequest) { if (isRequest) { request = data; response = empty(); setResponseId (getRequestId()); } else { request = empty(); response = data; } }
EnviJSONRPC::EnviJSONRPC(const String &initialData, const bool isRequest) { if (isRequest) { request = JSON::fromString(initialData); response = empty(true,true); setResponseId (getRequestId()); } else { request = empty(true,false); response = JSON::fromString(initialData); } }
void Packet_v1_Channel::Print_v1_Channel(std::string const &componentName, Manager const * manager) const { Print_v1(componentName, manager); std::cout << "[CHANNELID: " << getChannelId() << " {" << PROTOV1_CHANNEL_CHANNELID_SIZE << "}]" << "[CLIENTSESSIONID: " << getClientSessionId() << "{" << PROTOV1_CHANNEL_CLIENTSESSIONID_SIZE << "}]" << std::endl; int id = getRequestId(); if (id == CHANNEL_JOIN || id == CHANNEL_JOIN_OK || id == CHANNEL_JOIN_NOK_ALREADYINCHAN || id == CHANNEL_JOINED || id == CHANNEL_LEAVE_OK || id == CHANNEL_LEAVED) std::cout << "# ChannelName: '" << getChannelName() << "'" << std::endl; if (id == CHANNEL_JOINED || id == CHANNEL_LEAVED) std::cout << "# Login: '******'" << std::endl; if (id == CHANNEL_MESSAGE || id == CHANNEL_MESSAGE_RECV) std::cout << "# Message: '" << getMessage() << "'" << std::endl; }
char const *Packet_v1_Channel::getChannelName() const { assert(getRequestId() == CHANNEL_JOIN || getRequestId() == CHANNEL_JOIN_OK || getRequestId() == CHANNEL_JOIN_NOK_ALREADYINCHAN || getRequestId() == CHANNEL_JOINED || getRequestId() == CHANNEL_LEAVED || getRequestId() == CHANNEL_LEAVE_OK); return reinterpret_cast<char const *>(getData(PROTOV1_CHANNEL_START_OF_DATA, PROTOV1_CHANNEL_DATA_CHANNEL_NAME)); }
void Packet_v1_Channel::setChannelName(char const * name) { assert(getRequestId() == CHANNEL_JOIN || getRequestId() == CHANNEL_JOIN_OK || getRequestId() == CHANNEL_JOIN_NOK_ALREADYINCHAN || getRequestId() == CHANNEL_JOINED || getRequestId() == CHANNEL_LEAVED || getRequestId() == CHANNEL_LEAVE_OK); appendData(PROTOV1_CHANNEL_START_OF_DATA, PROTOV1_CHANNEL_DATA_CHANNEL_NAME, reinterpret_cast<byte_t const *>(name)); }
char const *Packet_v1_UserInfo::getAvatar() const { assert(getRequestId() == USERINFO_GETAVATAR_RESPONSE_OK); return reinterpret_cast<char const *>(getData(PROTOV1_USERINFO_START_OF_DATA, PROTOV1_USERINFO_DATA_AVATAR)); }
char const *Packet_v1_Channel::getMessage() const { assert(getRequestId() == CHANNEL_MESSAGE || getRequestId() == CHANNEL_MESSAGE_RECV); return reinterpret_cast<char const *>(getData(PROTOV1_CHANNEL_START_OF_DATA, PROTOV1_CHANNEL_DATA_MESSAGE)); }
void Packet_v1_Channel::setMessage(char const * message) { assert(getRequestId() == CHANNEL_MESSAGE || getRequestId() == CHANNEL_MESSAGE_RECV); appendData(PROTOV1_CHANNEL_START_OF_DATA, PROTOV1_CHANNEL_DATA_MESSAGE, reinterpret_cast<byte_t const *>(message)); }
char const *Packet_v1_Channel::getClientLogin() const { assert(getRequestId() == CHANNEL_JOINED || getRequestId() == CHANNEL_LEAVED); return reinterpret_cast<char const *>(getData(PROTOV1_CHANNEL_START_OF_DATA, PROTOV1_CHANNEL_DATA_LOGIN)); }
void Packet_v1_Channel::setClientLogin(char const *login) { assert(getRequestId() == CHANNEL_JOINED || getRequestId() == CHANNEL_LEAVED); appendData(PROTOV1_CHANNEL_START_OF_DATA, PROTOV1_CHANNEL_DATA_LOGIN, reinterpret_cast<byte_t const *>(login)); }