fixing issues from refactoring

This commit is contained in:
2025-04-06 01:30:39 +02:00
parent f891f317fb
commit 47694df8a3
7 changed files with 297 additions and 306 deletions
@@ -25,7 +25,7 @@ class SAD_DetectedServer {
m_ComputerName(p_ComputerName),
m_IP(p_IP),
m_Port(p_Port),
m_ClientIP(p_IP),
m_ClientIP(p_ClientIP),
m_Additions(p_Additions),
m_ServerProjectName(projName) {
}
@@ -126,14 +126,14 @@ class SAD_DetectedServer {
static void evaluateDetectedServers(I_SAD_Client &sadClient) {
for (auto &srv : sKnownServers) {
SAD_DetectedServer &known = *srv.second;
if (known.getFoundAgain() == false) {
sadClient.eventServerLost(known);
removeDetectedServer(known);
} else if (known.getNew()) {
if (known.getNew()) {
known.setKnown();
sadClient.eventServerDetected(known);
} else if (known.getChanged()) {
sadClient.eventServerChanged(known);
} else if (known.getFoundAgain() == false) {
sadClient.eventServerLost(known);
removeDetectedServer(known);
}
}
}
+14 -22
View File
@@ -79,13 +79,6 @@ class SPITSocket {
//-------- class --------------
SPITSocket(IPAddress ip) : mOwnIp(ip) {
m_UDPSocketIP4 = INVALID_SOCKET;
m_ServerIP = "";
m_ServerPort = "";
m_ClientIP = "";
m_ClientPort = "";
m_BoundClientPort = "";
m_IsBound = false;
createSocket_UDP();
}
virtual ~SPITSocket() {
@@ -101,12 +94,12 @@ class SPITSocket {
}
private:
string m_ServerIP;
string m_ServerPort;
string m_ClientIP;
string m_ClientPort; // port given by the user maybe "0"
string m_BoundClientPort; // port set after bind
bool m_IsBound;
string m_ServerIP{};
string m_ServerPort{};
string m_ClientIP{};
string m_ClientPort{}; // port given by the user maybe "0"
string m_BoundClientPort{}; // port set after bind
bool m_IsBound{};
public:
// Sets the ip address and port for server and client.
@@ -124,14 +117,14 @@ class SPITSocket {
* @return
*/
int sendMessage(const char *message, int length) {
if (m_ServerPort.length() <= 0)
if (m_ServerPort.length() <= 0) {
return -1;
int intResult;
{
if (m_IsBound == false)
return -1;
intResult = sendMessageTo(m_ServerIP, m_ServerPort, message, length);
}
if (m_IsBound == false) {
return -1;
}
int intResult = sendMessageTo(m_ServerIP, m_ServerPort, message, length);
return intResult;
}
@@ -139,7 +132,7 @@ class SPITSocket {
int setBroadcast(bool p_Broadcast) const;
int bindSocket(string clientIp, string clientPort);
int sendMessageTo(const string& ip, const string&port, const char *message, int msgLength);
int sendMessageTo(const string &ip, const string &port, const char *message, int msgLength);
string getServerIP() const { return m_ServerIP; }
string getServerPort() const { return m_ServerPort; }
@@ -150,8 +143,7 @@ class SPITSocket {
void setIsBound(bool p_IsBound) { m_IsBound = p_IsBound; }
bool getIsBound() const { return m_IsBound; }
private:
private:
};
#endif /* SPITSOCKET_H */
+1 -1
View File
@@ -107,7 +107,7 @@ class SPIT_Client : I_SAD_Client {
Callbacks mCallbacks;
fos::TaskT<SPIT_Client &> *m_ThreadReceive{};
bool m_StopReceiveSPITMessages;
bool m_StopReceiveSPITMessages{};
int m_ConnectionStatus;
bool m_DisconnectedByServer{}; // flag true = when server disconnects
+1 -1
View File
@@ -99,7 +99,7 @@ class SPIT_Message {
// Receive
OPPart(unique_ptr<Header> p_Header, int p_OPFlag, int size);
void setHeader(unique_ptr<Header> p_Header);
void setHeader(int opFlag);
virtual bool parse(const std::vector<char> &message) = 0;
// Send