got rid of some 'new' class creations

pull/14/head
Tom Early 6 years ago
parent 34699ff13e
commit 1591828218

@ -5,9 +5,8 @@
#include <string.h>
#include "IRCClient.h"
#include "IRCProtocol.h"
#include "IRCutils.h"
#include "IRCDDBApp.h"
IRCClient::IRCClient(IRCDDBApp *app, const std::string &update_channel, const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password, const std::string &versionInfo)
{
@ -21,17 +20,14 @@ IRCClient::IRCClient(IRCDDBApp *app, const std::string &update_channel, const st
this->app = app;
proto = new IRCProtocol(app, this->callsign, password, update_channel, versionInfo);
proto.Init(app, this->callsign, password, update_channel, versionInfo);
recvQ = NULL;
sendQ = NULL;
recv = NULL;
}
IRCClient::~IRCClient()
{
delete proto;
}
bool IRCClient::startWork()
@ -87,10 +83,10 @@ void IRCClient::Entry()
recvQ = new IRCMessageQueue();
sendQ = new IRCMessageQueue();
recv = new IRCReceiver(&ircSock, recvQ);
recv->startWork();
receiver.Init(&ircSock, recvQ);
receiver.startWork();
proto->setNetworkReady(true);
proto.setNetworkReady(true);
state = 5;
timer = 0;
break;
@ -104,7 +100,7 @@ void IRCClient::Entry()
if (recvQ->isEOF()) {
timer = 0;
state = 6;
} else if (proto->processQueues(recvQ, sendQ) == false) {
} else if (proto.processQueues(recvQ, sendQ) == false) {
timer = 0;
state = 6;
}
@ -145,12 +141,11 @@ void IRCClient::Entry()
app->userListReset();
}
proto->setNetworkReady(false);
recv->stopWork();
proto.setNetworkReady(false);
receiver.stopWork();
sleep(2);
delete recv;
delete recvQ;
delete sendQ;

@ -6,8 +6,9 @@
#include "IRCReceiver.h"
#include "IRCMessageQueue.h"
#include "IRCProtocol.h"
#include "IRCReceiver.h"
class IRCProtocol;
class IRCDDBApp;
class IRCClient
@ -34,10 +35,10 @@ private:
bool terminateThread;
IRCReceiver *recv;
IRCReceiver receiver;
IRCMessageQueue *recvQ;
IRCMessageQueue *sendQ;
IRCProtocol *proto;
IRCProtocol proto;
IRCDDBApp *app;
};

@ -6,10 +6,11 @@
#include "IRCutils.h"
#include "IRCProtocol.h"
#include "IRCMessageQueue.h"
#include "IRCDDBApp.h"
#define CIRCDDB_VERSION "2.0.0"
IRCProtocol::IRCProtocol(IRCDDBApp *app, const std::string &callsign, const std::string &password, const std::string &channel, const std::string &versionInfo)
void IRCProtocol::Init(IRCDDBApp *app, const std::string &callsign, const std::string &password, const std::string &channel, const std::string &versionInfo)
{
srand(time(NULL));
this->password = password;

@ -1,12 +1,14 @@
#pragma once
#include "IRCDDBApp.h"
#include "IRCMessageQueue.h"
class IRCDDBApp;
class IRCProtocol
{
public:
IRCProtocol(IRCDDBApp *app, const std::string &callsign, const std::string &password, const std::string &channel, const std::string &versionInfo);
IRCProtocol() {}
void Init(IRCDDBApp *app, const std::string &callsign, const std::string &password, const std::string &channel, const std::string &versionInfo);
~IRCProtocol();

@ -6,7 +6,7 @@
#include "IRCMessage.h"
#include "IRCReceiver.h"
IRCReceiver::IRCReceiver(CTCPReaderWriterClient *sock, IRCMessageQueue *q)
void IRCReceiver::Init(CTCPReaderWriterClient *sock, IRCMessageQueue *q)
{
ircSock = sock;
recvQ = q;

@ -6,7 +6,8 @@
class IRCReceiver
{
public:
IRCReceiver(CTCPReaderWriterClient *ircSock, IRCMessageQueue *q);
IRCReceiver() {}
void Init(CTCPReaderWriterClient *ircSock, IRCMessageQueue *q);
virtual ~IRCReceiver();
bool startWork();
void stopWork();

Loading…
Cancel
Save

Powered by TurnKey Linux.