void LoginSession::ListGameAccounts(XMLPacket *Packet) { rapidxml::xml_node<>* requestNode = Packet->m_XMLDocument.first_node("Request"); auto gameCode = requestNode->first_node("GameCode")->value(); /*GW2Packet packet = GW2Packet("/Presence/UserInfo", PT_MESSAGE); packet.AddElement("Status", "online"); packet.AddElement("Status", "online");*/ printf("Looking up game accounts...\n"); int sequence = Packet->m_Meta[2] - '0'; const char* temporary_guid = "068XXXXC-XXXX-XXXX-XXXX-XXXXD7XXXX75"; const char* temporary_username = "******"; GW2Packet messagePacket("/Presence/UserInfo", sequence, PT_MESSAGE); messagePacket.AddElement("Status", "online"); messagePacket.AddElement("Aliases", ""); messagePacket.AddElement("OnlineTimes", ""); messagePacket.AddElement("AppData", ""); messagePacket.AddElement("Channels", ""); messagePacket.AddElement("Groups", ""); messagePacket.AddElement("Contacts", ""); messagePacket.AddElement("UserId", temporary_guid); messagePacket.AddElement("UserCenter", "5"); messagePacket.AddElement("UserName", temporary_username); messagePacket.AddElement("ChangeId", "20"); messagePacket.AddElement("NewBeginning", ""); std::string compiledReply = ""; std::string temporaryGameList[] = { "STS/1.0 200 OK\r\n", "s:"+std::to_string(sequence)+"R\r\n", "l:136\r\n", "\r\n", "<Reply type=\"array\">\n", "<Row>\n" "<GameCode>gw2</GameCode>\n" "<Alias>Guild Wars 2</Alias>\n" "<Created>2016-06-13T01:07:20Z</Created>\n" "</Row>\n" "</Reply>\n" }; for (auto line : temporaryGameList) { compiledReply += line; } SessionSendPacket message; memset(message.m_TLSSendBuffer, 0, 4096); sprintf(message.m_TLSSendBuffer, messagePacket.Payload()); message.m_TLSSendBufferLength = strlen(message.m_TLSSendBuffer); message.m_TLSSendNeeded = true; m_SendPackets.push_back(message); SessionSendPacket gameArray; memset(gameArray.m_TLSSendBuffer, 0, 4096); sprintf(gameArray.m_TLSSendBuffer, compiledReply.c_str()); gameArray.m_TLSSendBufferLength = strlen(gameArray.m_TLSSendBuffer); gameArray.m_TLSSendNeeded = true; m_SendPackets.push_back(gameArray); }
void LoginSession::ListGameAccounts(XMLPacket *Packet) { rapidxml::xml_node<>* requestNode = Packet->m_XMLDocument.first_node("Request"); auto gameCode = requestNode->first_node("GameCode")->value(); int sequence = Packet->m_Meta[2] - '0'; std::string username; std::string userGuid; auto userQuery = Database::Get().PrepareQuery("SELECT * FROM cligate.Users where userEmail = %0q;"); auto result = userQuery.store(m_ClientEmail.c_str()); printf("Looking up game accounts...\n"); if (result.size() != 0) { if (result.size() > 1) { printf("Data consistency error, an email address appear's more than once in the users table."); } username = std::string(result.front()["userName"]).c_str(); userGuid = std::string(result.front()["userGuid"]).c_str(); } printf("Fetching game accounts for %s.\n", m_ClientEmail.c_str()); printf("User GUID %s.\n", userGuid.c_str()); GW2Packet messagePacket("/Presence/UserInfo", sequence, PT_MESSAGE); messagePacket.AddElement("Status", "online"); messagePacket.AddElement("Aliases", ""); messagePacket.AddElement("OnlineTimes", ""); messagePacket.AddElement("AppData", ""); messagePacket.AddElement("Channels", ""); messagePacket.AddElement("Groups", ""); messagePacket.AddElement("Contacts", ""); messagePacket.AddElement("UserId", userGuid.c_str()); messagePacket.AddElement("UserCenter", "5"); messagePacket.AddElement("UserName", username.c_str()); messagePacket.AddElement("ChangeId", "20"); messagePacket.AddElement("NewBeginning", ""); std::string compiledReply = ""; std::string temporaryGameList[] = { "STS/1.0 200 OK\r\n", "s:"+std::to_string(sequence)+"R\r\n", "l:136\r\n", "\r\n", "<Reply type=\"array\">\n", "<Row>\n" "<GameCode>gw2</GameCode>\n" "<Alias>Guild Wars 2</Alias>\n" "<Created>2016-06-13T01:07:20Z</Created>\n" "</Row>\n" "</Reply>\n" }; for (auto line : temporaryGameList) { compiledReply += line; } SessionSendPacket message; memset(message.m_TLSSendBuffer, 0, 4096); sprintf(message.m_TLSSendBuffer, messagePacket.Payload()); message.m_TLSSendBufferLength = (int)strlen(message.m_TLSSendBuffer); message.m_TLSSendNeeded = true; m_SendPackets.push_back(message); SessionSendPacket gameArray; memset(gameArray.m_TLSSendBuffer, 0, 4096); sprintf(gameArray.m_TLSSendBuffer, compiledReply.c_str()); gameArray.m_TLSSendBufferLength = (int)strlen(gameArray.m_TLSSendBuffer); gameArray.m_TLSSendNeeded = true; m_SendPackets.push_back(gameArray); }