aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp13
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([&currentUserKeyPair, &channels, &channelMessageMutex](const odhtdb::DatabaseAddUserRequest &request)
+ database.setOnAddUserCallback([&currentUserKeyPair, &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", [&currentUserKeyPair, &database, &localNodeUsers, &channelMessageMutex](const vector<string> &args)
+ Command::add("jc", [&currentUserKeyPair, &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))
{