Debian Codegraph @

src/CommClient.cpp

raw symbols SCIP
1 #include "CommClient.h"
2 #include "OpenMSXConnection.h"
3
4 CommClient::~CommClient()
5 {
6 closeConnection();
7 }
8
9 CommClient& CommClient::instance()
10 {
11 static CommClient oneInstance;
12 return oneInstance;
13 }
14
15 void CommClient::connectToOpenMSX(std::unique_ptr<OpenMSXConnection> conn)
16 {
17 closeConnection();
18 connection = std::move(conn);
19 connect(connection.get(), &OpenMSXConnection::disconnected, this, &CommClient::closeConnection);
20 connect(connection.get(), &OpenMSXConnection::logParsed, this, &CommClient::logParsed);
21 connect(connection.get(), &OpenMSXConnection::updateParsed, this, &CommClient::updateParsed);
22 emit connectionReady();
23 }
24
25 void CommClient::closeConnection()
26 {
27 if (connection) {
28 connection.reset();
29 emit connectionTerminated();
30 }
31 }
32
33 void CommClient::sendCommand(CommandBase* command)
34 {
35 if (connection) {
36 connection->sendCommand(command);
37 } else {
38 command->cancel();
39 }
40 }