class Network: needless function 'addQueue' removed.

This commit is contained in:
Roland Jax
2014-11-11 20:07:59 +01:00
parent 694f22c718
commit e8d4fbaff5
4 changed files with 9 additions and 11 deletions
+2 -3
View File
@@ -39,8 +39,7 @@ BaseLoop::BaseLoop()
m_ebusloop->start("ebusloop");
// create Network
m_network = new Network(A.getParam<bool>("p_localhost"));
m_network->addQueue(&m_queue);
m_network = new Network(A.getParam<bool>("p_localhost"), &m_msgQueue);
m_network->start("network");
}
@@ -68,7 +67,7 @@ void BaseLoop::start()
std::string result;
// recv new message from client
Message* message = m_queue.remove();
Message* message = m_msgQueue.remove();
std::string data = message->getData();
data.erase(std::remove(data.begin(), data.end(), '\r'), data.end());
+2 -2
View File
@@ -36,14 +36,14 @@ public:
void start();
void addMessage(Message* message) { m_queue.add(message); }
void addMessage(Message* message) { m_msgQueue.add(message); }
private:
Commands* m_commands;
EBusLoop* m_ebusloop;
Network* m_network;
WQueue<Message*> m_queue;
WQueue<Message*> m_msgQueue;
enum ClientCommand {
get, // get ebus data
+3 -2
View File
@@ -25,7 +25,8 @@ extern LogInstance& L;
extern Appl& A;
Network::Network(const bool localhost) : m_listening(false), m_running(false)
Network::Network(const bool localhost, WQueue<Message*>* msgQueue)
: m_msgQueue(msgQueue), m_listening(false), m_running(false)
{
if (localhost == true)
m_Server = new TCPServer(A.getParam<int>("p_port"), "127.0.0.1");
@@ -100,7 +101,7 @@ void* Network::run()
if (socket == NULL)
continue;
Connection* connection = new Connection(socket, m_queue);
Connection* connection = new Connection(socket, m_msgQueue);
if (connection == NULL)
continue;
+2 -4
View File
@@ -26,17 +26,15 @@ class Network : public Thread
{
public:
Network(const bool localhost);
Network(const bool localhost, WQueue<Message*>* msgQueue);
~Network();
void addQueue(WQueue<Message*>* queue) { m_queue = queue; }
void* run();
void stop() const { m_notify.notify(); usleep(100000); }
private:
std::list<Connection*> m_connections;
WQueue<Message*>* m_queue;
WQueue<Message*>* m_msgQueue;
TCPServer* m_Server;
Notify m_notify;
bool m_listening;