void Battlenet::Session::HandleListSubscribeRequest(WoWRealm::ListSubscribeRequest const& /*listSubscribeRequest*/) { WoWRealm::ListSubscribeResponse* listSubscribeResponse = new WoWRealm::ListSubscribeResponse(); PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_CHARACTER_COUNTS); stmt->setUInt32(0, _gameAccountId); if (PreparedQueryResult countResult = LoginDatabase.Query(stmt)) { do { Field* fields = countResult->Fetch(); uint32 build = fields[4].GetUInt32(); listSubscribeResponse->CharacterCounts.push_back({ RealmId(fields[2].GetUInt8(), fields[3].GetUInt8(), fields[1].GetUInt32(), (_build != build ? build : 0)), fields[0].GetUInt8() }); } while (countResult->NextRow()); } for (RealmList::RealmMap::value_type const& i : sRealmList->GetRealms()) listSubscribeResponse->RealmData.push_back(BuildListUpdate(&i.second)); listSubscribeResponse->RealmData.push_back(new WoWRealm::ListComplete()); AsyncWrite(listSubscribeResponse); _subscribedToRealmListUpdates = true; }
void Battlenet::Session::UpdateRealms(std::vector<Realm const*>& realms, std::vector<Battlenet::RealmHandle>& deletedRealms) { for (Realm const* realm : realms) AsyncWrite(BuildListUpdate(realm)); for (Battlenet::RealmHandle& deleted : deletedRealms) { WoWRealm::ListUpdate* listUpdate = new WoWRealm::ListUpdate(); listUpdate->UpdateState = WoWRealm::ListUpdate::DELETED; listUpdate->Id = deleted; AsyncWrite(listUpdate); } }
void Battlenet::Session::HandleListSubscribeRequestCallback(PreparedQueryResult result) { WoWRealm::ListSubscribeResponse* listSubscribeResponse = new WoWRealm::ListSubscribeResponse(); if (result) { do { Field* fields = result->Fetch(); listSubscribeResponse->CharacterCounts.push_back({ Battlenet::RealmHandle(fields[2].GetUInt8(), fields[3].GetUInt8(), fields[1].GetUInt32()), fields[0].GetUInt8() }); } while (result->NextRow()); } AsyncWrite(listSubscribeResponse); for (RealmList::RealmMap::value_type const& i : sRealmList->GetRealms()) AsyncWrite(BuildListUpdate(&i.second)); AsyncWrite(new WoWRealm::ListComplete()); _subscribedToRealmListUpdates = true; }