diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-05-01 14:58:16 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-05-01 14:58:19 +0200 |
commit | 8b1d23b390b8184c028de10138a3ffeb27421e7f (patch) | |
tree | 03b2bc1eef21f3a7aa6bb7b683c8d323af527a7c /src | |
parent | 98bf43608e1187b164481d83501226d897e77d57 (diff) |
Use new odhtdb with timestamp bug fix, fix waiting msg
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp index 03f6a81..1e63d70 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -111,8 +111,9 @@ int main(int argc, char **argv) string currentUserName; string currentUserPassword; recursive_mutex channelMessageMutex; + bool waitingToJoin = false; - database.setOnCreateNodeCallback([&waitingToJoinChannels, &database, &channels, &channelMessageMutex](const odhtdb::DatabaseCreateNodeRequest &request) + database.setOnCreateNodeCallback([&waitingToJoinChannels, &database, &channels, &channelMessageMutex, &waitingToJoin](const odhtdb::DatabaseCreateNodeRequest &request) { lock_guard<recursive_mutex> lock(channelMessageMutex); for(vector<odhtdb::DatabaseNode>::iterator it = waitingToJoinChannels.begin(); it != waitingToJoinChannels.end(); ++it) @@ -127,6 +128,7 @@ int main(int argc, char **argv) User *nodeCreatorUser = new OnlineUser(request.creatorUser); channel->addUserLocally(nodeCreatorUser); + waitingToJoin = true; waitingToJoinChannels.erase(it); return; @@ -155,7 +157,7 @@ int main(int argc, char **argv) } }); - database.setOnAddUserCallback([¤tUserKeyPair, &channels, &channelMessageMutex](const odhtdb::DatabaseAddUserRequest &request) + database.setOnAddUserCallback([¤tUserKeyPair, &channels, &channelMessageMutex, &waitingToJoin](const odhtdb::DatabaseAddUserRequest &request) { lock_guard<recursive_mutex> lock(channelMessageMutex); if(currentUserKeyPair && request.userToAdd->getPublicKey() == currentUserKeyPair->getPublicKey()) @@ -172,6 +174,7 @@ int main(int argc, char **argv) if(userToAdd && currentUserKeyPair && request.userToAdd->getPublicKey() == currentUserKeyPair->getPublicKey() && channel->getLocalUser()->type != User::Type::ONLINE) { channel->replaceLocalUser(new OnlineUser(request.userToAdd)); + waitingToJoin = false; return; } @@ -359,7 +362,7 @@ int main(int argc, char **argv) } }); - Command::add("jc", [¤tUserKeyPair, &database, &localNodeUsers, &channelMessageMutex](const vector<string> &args) + Command::add("jc", [¤tUserKeyPair, &database, &localNodeUsers, &channelMessageMutex, &waitingToJoin](const vector<string> &args) { lock_guard<recursive_mutex> lock(channelMessageMutex); if(args.size() != 1) @@ -391,6 +394,7 @@ int main(int argc, char **argv) } database.seed(databaseNode); + waitingToJoin = true; // TODO: Add the channel to join to a pending join list in a file and remove from it when we have joined the channel. // The reason for doing that is so if we crash or lose internet connection before we have got `create node` request from remote peers, // then we need to start seeding again when we login. Once we have `create node` request, then it's added to local cache and when you login, @@ -447,10 +451,7 @@ int main(int argc, char **argv) sf::Event event; while (window.isOpen()) { - channelMessageMutex.lock(); Channel *currentChannel = Channel::getCurrent(); - bool waitingToJoin = currentChannel != &offlineChannel && currentChannel->getLocalUser()->type != User::Type::ONLINE; - channelMessageMutex.unlock(); while (window.pollEvent(event)) { |