class Network: needless function 'addQueue' removed.
This commit is contained in:
@@ -39,8 +39,7 @@ BaseLoop::BaseLoop()
|
|||||||
m_ebusloop->start("ebusloop");
|
m_ebusloop->start("ebusloop");
|
||||||
|
|
||||||
// create Network
|
// create Network
|
||||||
m_network = new Network(A.getParam<bool>("p_localhost"));
|
m_network = new Network(A.getParam<bool>("p_localhost"), &m_msgQueue);
|
||||||
m_network->addQueue(&m_queue);
|
|
||||||
m_network->start("network");
|
m_network->start("network");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +67,7 @@ void BaseLoop::start()
|
|||||||
std::string result;
|
std::string result;
|
||||||
|
|
||||||
// recv new message from client
|
// recv new message from client
|
||||||
Message* message = m_queue.remove();
|
Message* message = m_msgQueue.remove();
|
||||||
std::string data = message->getData();
|
std::string data = message->getData();
|
||||||
|
|
||||||
data.erase(std::remove(data.begin(), data.end(), '\r'), data.end());
|
data.erase(std::remove(data.begin(), data.end(), '\r'), data.end());
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ public:
|
|||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
void addMessage(Message* message) { m_queue.add(message); }
|
void addMessage(Message* message) { m_msgQueue.add(message); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Commands* m_commands;
|
Commands* m_commands;
|
||||||
EBusLoop* m_ebusloop;
|
EBusLoop* m_ebusloop;
|
||||||
Network* m_network;
|
Network* m_network;
|
||||||
|
|
||||||
WQueue<Message*> m_queue;
|
WQueue<Message*> m_msgQueue;
|
||||||
|
|
||||||
enum ClientCommand {
|
enum ClientCommand {
|
||||||
get, // get ebus data
|
get, // get ebus data
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ extern LogInstance& L;
|
|||||||
extern Appl& A;
|
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)
|
if (localhost == true)
|
||||||
m_Server = new TCPServer(A.getParam<int>("p_port"), "127.0.0.1");
|
m_Server = new TCPServer(A.getParam<int>("p_port"), "127.0.0.1");
|
||||||
@@ -100,7 +101,7 @@ void* Network::run()
|
|||||||
if (socket == NULL)
|
if (socket == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Connection* connection = new Connection(socket, m_queue);
|
Connection* connection = new Connection(socket, m_msgQueue);
|
||||||
if (connection == NULL)
|
if (connection == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -26,17 +26,15 @@ class Network : public Thread
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Network(const bool localhost);
|
Network(const bool localhost, WQueue<Message*>* msgQueue);
|
||||||
~Network();
|
~Network();
|
||||||
|
|
||||||
void addQueue(WQueue<Message*>* queue) { m_queue = queue; }
|
|
||||||
|
|
||||||
void* run();
|
void* run();
|
||||||
void stop() const { m_notify.notify(); usleep(100000); }
|
void stop() const { m_notify.notify(); usleep(100000); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<Connection*> m_connections;
|
std::list<Connection*> m_connections;
|
||||||
WQueue<Message*>* m_queue;
|
WQueue<Message*>* m_msgQueue;
|
||||||
TCPServer* m_Server;
|
TCPServer* m_Server;
|
||||||
Notify m_notify;
|
Notify m_notify;
|
||||||
bool m_listening;
|
bool m_listening;
|
||||||
|
|||||||
Reference in New Issue
Block a user