rename sendJoin to joinChannel

This commit is contained in:
Rasmus Karlsson 2017-06-06 16:06:13 +02:00
parent 6a5d4d49ee
commit 6acaa56442
3 changed files with 20 additions and 20 deletions

View file

@ -58,7 +58,7 @@ SharedChannel ChannelManager::addChannel(const QString &channel)
auto channel = SharedChannel(new Channel(channelName)); auto channel = SharedChannel(new Channel(channelName));
_channels.insert(channelName, std::make_tuple(channel, 1)); _channels.insert(channelName, std::make_tuple(channel, 1));
IrcManager::getInstance().sendJoin(channelName); IrcManager::getInstance().joinChannel(channelName);
return channel; return channel;
} }

View file

@ -169,8 +169,7 @@ void IrcManager::beginConnecting()
this->readConnection->moveToThread(QCoreApplication::instance()->thread()); this->readConnection->moveToThread(QCoreApplication::instance()->thread());
for (auto &channel : ChannelManager::getInstance().getItems()) { for (auto &channel : ChannelManager::getInstance().getItems()) {
this->writeConnection->sendRaw("JOIN #" + channel->getName()); this->joinChannel(channel->getName());
this->readConnection->sendRaw("JOIN #" + channel->getName());
} }
this->writeConnection->open(); this->writeConnection->open();
@ -194,18 +193,6 @@ void IrcManager::disconnect()
_connectionMutex.unlock(); _connectionMutex.unlock();
} }
void IrcManager::sendJoin(const QString &channel)
{
_connectionMutex.lock();
if (this->readConnection && this->writeConnection) {
this->readConnection->sendRaw("JOIN #" + channel);
this->writeConnection->sendRaw("JOIN #" + channel);
}
_connectionMutex.unlock();
}
void IrcManager::sendMessage(const QString &channelName, const QString &message) void IrcManager::sendMessage(const QString &channelName, const QString &message)
{ {
_connectionMutex.lock(); _connectionMutex.lock();
@ -217,13 +204,26 @@ void IrcManager::sendMessage(const QString &channelName, const QString &message)
_connectionMutex.unlock(); _connectionMutex.unlock();
} }
void IrcManager::partChannel(const QString &channel) void IrcManager::joinChannel(const QString &channelName)
{ {
_connectionMutex.lock(); _connectionMutex.lock();
if (this->readConnection && this->writeConnection) { if (this->readConnection && this->writeConnection) {
this->readConnection->sendRaw("PART #" + channel); this->readConnection->sendRaw("JOIN #" + channelName);
this->writeConnection->sendRaw("PART #" + channel); this->writeConnection->sendRaw("JOIN #" + channelName);
}
_connectionMutex.unlock();
}
void IrcManager::partChannel(const QString &channelName)
{
_connectionMutex.lock();
if (this->readConnection && this->writeConnection) {
this->readConnection->sendRaw("PART #" + channelName);
this->writeConnection->sendRaw("PART #" + channelName);
} }
_connectionMutex.unlock(); _connectionMutex.unlock();

View file

@ -38,10 +38,10 @@ public:
QNetworkAccessManager &getAccessManager(); QNetworkAccessManager &getAccessManager();
void sendJoin(const QString &channel);
void sendMessage(const QString &channelName, const QString &message); void sendMessage(const QString &channelName, const QString &message);
void partChannel(const QString &channel); void joinChannel(const QString &channelName);
void partChannel(const QString &channelName);
const twitch::TwitchUser &getUser() const; const twitch::TwitchUser &getUser() const;
void setUser(const twitch::TwitchUser &account); void setUser(const twitch::TwitchUser &account);