added code to handle a single connection
This commit is contained in:
@@ -35,26 +35,18 @@ AbstractIrcServer::AbstractIrcServer()
|
||||
// this->writeConnection->reconnectRequested.connect([this] { this->connect(); });
|
||||
}
|
||||
|
||||
IrcConnection *AbstractIrcServer::getReadConnection() const
|
||||
{
|
||||
return this->readConnection_.get();
|
||||
}
|
||||
|
||||
IrcConnection *AbstractIrcServer::getWriteConnection() const
|
||||
{
|
||||
return this->writeConnection_.get();
|
||||
}
|
||||
|
||||
void AbstractIrcServer::connect()
|
||||
{
|
||||
this->disconnect();
|
||||
|
||||
// if (this->hasSeparateWriteConnection()) {
|
||||
this->initializeConnection(this->writeConnection_.get(), false, true);
|
||||
this->initializeConnection(this->readConnection_.get(), true, false);
|
||||
// } else {
|
||||
// this->initializeConnection(this->readConnection.get(), true, true);
|
||||
// }
|
||||
bool separateWriteConnection = this->hasSeparateWriteConnection();
|
||||
|
||||
if (separateWriteConnection) {
|
||||
this->initializeConnection(this->writeConnection_.get(), false, true);
|
||||
this->initializeConnection(this->readConnection_.get(), true, false);
|
||||
} else {
|
||||
this->initializeConnection(this->readConnection_.get(), true, true);
|
||||
}
|
||||
|
||||
// fourtf: this should be asynchronous
|
||||
{
|
||||
@@ -67,7 +59,6 @@ void AbstractIrcServer::connect()
|
||||
continue;
|
||||
}
|
||||
|
||||
this->writeConnection_->sendRaw("JOIN #" + chan->name);
|
||||
this->readConnection_->sendRaw("JOIN #" + chan->name);
|
||||
}
|
||||
|
||||
@@ -88,13 +79,18 @@ void AbstractIrcServer::disconnect()
|
||||
}
|
||||
|
||||
void AbstractIrcServer::sendMessage(const QString &channelName, const QString &message)
|
||||
{
|
||||
this->sendRawMessage("PRIVMSG #" + channelName + " :" + message);
|
||||
}
|
||||
|
||||
void AbstractIrcServer::sendRawMessage(const QString &rawMessage)
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(this->connectionMutex_);
|
||||
|
||||
// fourtf: trim the message if it's sent from twitch chat
|
||||
|
||||
if (this->writeConnection_) {
|
||||
this->writeConnection_->sendRaw("PRIVMSG #" + channelName + " :" + message);
|
||||
if (this->hasSeparateWriteConnection()) {
|
||||
this->writeConnection_->sendRaw(rawMessage);
|
||||
} else {
|
||||
this->readConnection_->sendRaw(rawMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user