Added number of currently logged in users
This commit is contained in:
@@ -276,7 +276,7 @@ std::string App::getGenderShortByGender(std::string gender) {
|
||||
return "";
|
||||
}
|
||||
|
||||
void App::updateUserlist(Wt::Json::Array unsortedUserList) {
|
||||
void App::updateUserlist(Wt::Json::Array unsortedUserList, int size) {
|
||||
userListContainer_->clear();
|
||||
userListContainer_->resize(Wt::WLength(15, Wt::LengthUnit::FontEm), Wt::WLength::Auto);
|
||||
auto layout = userListContainer_->setLayout(std::make_unique<Wt::WVBoxLayout>());
|
||||
@@ -284,6 +284,7 @@ void App::updateUserlist(Wt::Json::Array unsortedUserList) {
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
userListContainer_->setOverflow(Wt::Overflow::Auto, Wt::Orientation::Vertical);
|
||||
userListContainer_->setOverflow(Wt::Overflow::Hidden, Wt::Orientation::Horizontal);
|
||||
layout->addNew<Wt::WText>(Wt::WString("Logged in: {1}").arg(size));
|
||||
auto sortedUserList = sortUserList(unsortedUserList);
|
||||
for (Wt::Json::Object &user: sortedUserList) {
|
||||
addUserItemToLayout(layout, user);
|
||||
@@ -1073,7 +1074,7 @@ void App::incomingBroadcast() {
|
||||
auto broadcasts = server_.getBroadcastsForSession(sessionId());
|
||||
for (Wt::Json::Object &broadcast: broadcasts) {
|
||||
if (broadcast["type"] == "userlist") {
|
||||
updateUserlist(broadcast["data"]);
|
||||
updateUserlist(broadcast["data"], (int)broadcast["count"]);
|
||||
} else if (broadcast["type"] == "logout") {
|
||||
server_.disconnect(this);
|
||||
} else if (broadcast["type"] == "messagequeue") {
|
||||
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
void handleLogin(Wt::WLineEdit *userName, Wt::WComboBox *countryWidget, Wt::WSpinBox *ageWidget, Wt::WComboBox *genderWidget);
|
||||
void populateGenderComboBox(Wt::WComboBox *genderWidget);
|
||||
std::string getGenderShortByGender(std::string gender);
|
||||
void updateUserlist(Wt::Json::Array userList);
|
||||
void updateUserlist(Wt::Json::Array userList, int size);
|
||||
std::vector<Wt::Json::Object> sortUserList(Wt::Json::Array unsortedUserList);
|
||||
void createMenu();
|
||||
void addLeaveButton();
|
||||
|
||||
Reference in New Issue
Block a user