refactor: simplifying project until runs on embedded system
This commit is contained in:
@@ -14,30 +14,42 @@
|
||||
#ifndef SPIT_CLIENT_H
|
||||
#define SPIT_CLIENT_H
|
||||
|
||||
#include "_SPITMACROS.h"
|
||||
#include "UnixSocket.h"
|
||||
|
||||
#include "SPITSocket.h"
|
||||
#include "SAD_Client.h"
|
||||
#include "SAD_ClientInterface.h"
|
||||
#include "SAD_DetectedServer.h"
|
||||
#include "SPIT_ClientInterface.h"
|
||||
#include "SAD_DetectedServer.hpp"
|
||||
#include "SPIT_Message.h"
|
||||
#include "Watchdog.h"
|
||||
#include "SPITType.h"
|
||||
#include "SPITObject.h"
|
||||
#include "SPIT_Handler.h"
|
||||
#include "SPITPlayer.h"
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//static char nullChar[] = "\0";
|
||||
class SPIT_Client : I_SAD_Client {
|
||||
|
||||
class SPIT_Client : SAD_ClientInterface, Watchdog::Listener {
|
||||
public:
|
||||
/** Maximal length of a SPITMessage*/
|
||||
static const int MAXSPITMESSAGEBYTECOUNT = 512;
|
||||
|
||||
struct Callbacks {
|
||||
void(*onServerDetect)(const SAD_DetectedServer &p_DetectedServer);
|
||||
void(*onServerLost)(const SAD_DetectedServer &p_DetectedServer);
|
||||
void(*onStartProjectTransfer)();
|
||||
void(*onEndProjectTransfer)();
|
||||
void(*onProjectClosed)(string);
|
||||
void(*onProjectReport)(string p_ProjectID, string p_ProjectName, int p_FramesPerSeoond);
|
||||
void(*onSpitType)(bool p_New, const SPITType &p_SPITType);
|
||||
void(*onSpitTypeRemote)(bool p_New, const SPITType &p_SPITType);
|
||||
void(*onSpitObject)(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
||||
void(*onSpitObjectRemote)(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
||||
void(*onSpitTypeRemoved)(const SPITType &p_SPITType);
|
||||
void(*onSpitTypeRemoteRemoved)(const SPITType &p_SPITType);
|
||||
void(*onSpitObjectRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
||||
void(*onSpitObjectRemoteRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
||||
void(*onPlay)(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames);
|
||||
void(*onPlayObject)(string p_PlayerID, bool p_Started, bool p_Stopped, const SPITType &p_SPITType, const SPITObject &p_SPITObject, const SPITPlayer::PlayObject &p_PlayObject);
|
||||
void(*onPlayRemoteObjectStatus)(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value);
|
||||
};
|
||||
|
||||
//----- Connection Status -----
|
||||
public:
|
||||
/** No Connection established.<br>Either no connect tried or disconnected*/
|
||||
@@ -46,7 +58,7 @@ public:
|
||||
static const int CONNECTION_NONESERVER = 1;
|
||||
/** The connection is lost<br>Either because of a network crash or because the server no longer responds.*/
|
||||
static const int CONNECTION_LOST = 2;
|
||||
/** Connection to the server is established.*/
|
||||
/** Connection to the serv er is established.*/
|
||||
static const int CONNECTION_OK = 3;
|
||||
/** A connection to the server is tried.*/
|
||||
static const int CONNECTION_TRYCONNECTION = 4;
|
||||
@@ -72,48 +84,38 @@ public:
|
||||
|
||||
//----- SPIT_Client -----
|
||||
public:
|
||||
static SPITSocket* createSPITSocket();
|
||||
public:
|
||||
SPIT_Client(SPIT_ClientInterface* p_SPITClientInterface);
|
||||
SPIT_Client(string name, string projName, Callbacks calls);
|
||||
virtual ~SPIT_Client();
|
||||
private:
|
||||
/** SPITClientInterface, normally the user app should implement this*/
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
SPITSocket* m_SPITSocket;
|
||||
fos::Mutex m_MutexSPITSocket;
|
||||
fos::TaskT<SPIT_Client&> * m_ThreadReceive;
|
||||
Callbacks mCallbacks;
|
||||
|
||||
fos::TaskT<SPIT_Client&> * m_ThreadReceive{};
|
||||
bool m_StopReceiveSPITMessages;
|
||||
|
||||
|
||||
int m_ConnectionStatus;
|
||||
bool m_DisconnectedByServer; //flag true = when server disconnects
|
||||
bool m_DisconnectedByServer{}; //flag true = when server disconnects
|
||||
string m_ID;
|
||||
string m_Name;
|
||||
string m_ProjName;
|
||||
string m_ComputerName;
|
||||
|
||||
//Server's info filled by parseConnectAnswer
|
||||
string m_ServerID;
|
||||
string m_ServerName;
|
||||
string m_ServerComputerName;
|
||||
int m_ServerStepTime;
|
||||
|
||||
|
||||
Watchdog* m_Watchdog;
|
||||
string m_ServerID{};
|
||||
string m_ServerName{};
|
||||
string m_ServerComputerName{};
|
||||
int m_ServerStepTime{-1};
|
||||
|
||||
unsigned char m_MessageNumber_Send;
|
||||
int m_MessageNumber_Received;
|
||||
|
||||
//--- Server Project ---
|
||||
string m_ServerProjectID;
|
||||
string m_ServerProjectName;
|
||||
int m_ServerFramesPerSecond;
|
||||
|
||||
public:
|
||||
SPIT_ClientInterface* getSPITClientInterface() {
|
||||
return m_SPITClientInterface;
|
||||
}
|
||||
|
||||
public:
|
||||
/** The ID of the client.<br>Every client instance should set an unique id*/
|
||||
string getID();
|
||||
/** Set the name of the client, should be done by the user app*/
|
||||
void setName(string p_Name);
|
||||
/** The name of the client, should be set by the user app*/
|
||||
string getName();
|
||||
//----- Computer Params -----
|
||||
@@ -153,10 +155,12 @@ private:
|
||||
bool startReceiveSPITMessages();
|
||||
void stopReceiveSPITMessages();
|
||||
static void receiveSPITMessage(SPIT_Client& rM);
|
||||
int sendSPITMessage(SPIT_Message::OPPart* p_SPITMessageOPPart);
|
||||
int sendSPITMessage(SPIT_Message::OPPart& p_SPITMessageOPPart);
|
||||
void fillHeader(SPIT_Message::Header* p_Header);
|
||||
|
||||
|
||||
// Reconnect to the server when connection is lost see eventConnectionStatus and eventServerDetected
|
||||
bool _doReconnect{}; // true = on eventServerDetected connect to the server identified by m_ServerID
|
||||
|
||||
//--------------- ServerAutoDetection SAD ---------------
|
||||
public:
|
||||
/** Starts the autodetection of SPITServers in the local network. If a connection is tried, the autodetection should be stopped before.*/
|
||||
@@ -164,48 +168,10 @@ public:
|
||||
/** Stops the autodetection of SPITServers in the local network*/
|
||||
void stopServerAutoDetect();
|
||||
/** Called every time a new SPITServer is detetced in the local network */
|
||||
void eventServerDetected(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ClientIP, bool p_isLoopback, bool p_IsIP4, bool p_IsIP6);
|
||||
void eventServerDetected(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ClientIP, bool p_IsIP4);
|
||||
/** Called every time a prior detected SPITServer is is no longer found.*/
|
||||
void eventServerLost(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ClientIP, bool p_isLoopback, bool p_IsIP4, bool p_IsIP6);
|
||||
void eventServerLost(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ClientIP, bool p_IsIP4);
|
||||
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyServerDetected: virtual public SPIT_Handler::Runnable {
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
SAD_DetectedServer m_DetectedServer;
|
||||
public:
|
||||
NotifyServerDetected(SPIT_ClientInterface* p_SPITClientInterface, const SAD_DetectedServer& p_DetetctedServer) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_DetectedServer = p_DetetctedServer;
|
||||
}
|
||||
~NotifyServerDetected(){}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
m_SPITClientInterface->eventServerDetected(m_DetectedServer);
|
||||
}
|
||||
}
|
||||
};
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyServerLost: virtual public SPIT_Handler::Runnable {
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
SAD_DetectedServer m_DetectedServer;
|
||||
public:
|
||||
NotifyServerLost(SPIT_ClientInterface* p_SPITClientInterface, const SAD_DetectedServer& p_DetetctedServer) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_DetectedServer = p_DetetctedServer;
|
||||
}
|
||||
~NotifyServerLost() {}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
m_SPITClientInterface->eventServerLost(m_DetectedServer);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------- Connection ---------------
|
||||
public:
|
||||
@@ -228,7 +194,7 @@ public:
|
||||
|
||||
private:
|
||||
void disconnectInternal(int p_Cause);
|
||||
void parseSPIT_Message(SPIT_Message* p_SPITMessage);
|
||||
void parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
||||
void parseConnectAnswer(SPIT_Message::ConnectAnswer* p_ConnectAnswer);
|
||||
void parseDisconnect(SPIT_Message::Disconnect* p_Disconnect);
|
||||
void parseWatchdog(SPIT_Message::Watchdog* p_Watchdog);
|
||||
@@ -238,36 +204,6 @@ public:
|
||||
void sendWatchdog();
|
||||
/** Used internally. When the connection to the SPITServer is lost an eventConnectionStatus will occur*/
|
||||
void eventWatchdogLost();
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyConnectionStatus : public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyConnectionStatus(SPIT_ClientInterface* p_SPITClientInterface, string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime,
|
||||
int p_NewConnectionStatus, int p_OldConnectionStatus) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_ServerID = p_ServerID;
|
||||
m_ServerComputerName = p_ServerComputerName;
|
||||
m_ServerName = p_ServerName;
|
||||
m_ServerStepTime = p_ServerStepTime;
|
||||
m_NewConnectionStatus = p_NewConnectionStatus;
|
||||
m_OldConnectionStatus = p_OldConnectionStatus;
|
||||
}
|
||||
~NotifyConnectionStatus() {}
|
||||
void run (){
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
m_SPITClientInterface->eventConnectionStatus(m_ServerComputerName, m_ServerID, m_ServerName, m_ServerStepTime, m_NewConnectionStatus, m_OldConnectionStatus);
|
||||
}
|
||||
}
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
string m_ServerID;
|
||||
string m_ServerComputerName;
|
||||
string m_ServerName;
|
||||
int m_ServerStepTime;
|
||||
int m_NewConnectionStatus;
|
||||
int m_OldConnectionStatus;
|
||||
};
|
||||
|
||||
//--------------- SPIT Project ---------------
|
||||
private:
|
||||
void parseReportSPITProject(SPIT_Message::ReportSPITProject* p_ReportSPITProject);
|
||||
@@ -279,84 +215,11 @@ public:
|
||||
string getServerProjectName();
|
||||
/** Returns frame rate per second. This is the time resolution in which the server transmits time data. The unit of time data is always frames.*/
|
||||
int getServerFramesPerSecond();
|
||||
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyReportProject : public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyReportProject(SPIT_ClientInterface* p_SPITClientInterface, string p_ProjectID, string p_ProjectName, int p_FramesPerSecond) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_ProjectID = p_ProjectID;
|
||||
m_ProjectName = p_ProjectName;
|
||||
m_FramesPerSecond = p_FramesPerSecond;
|
||||
}
|
||||
~NotifyReportProject() {}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
m_SPITClientInterface->eventProjectReport(m_ProjectID, m_ProjectName, m_FramesPerSecond);
|
||||
}
|
||||
}
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
string m_ProjectID;
|
||||
string m_ProjectName;
|
||||
int m_FramesPerSecond;
|
||||
};
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyProjectClosed : public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyProjectClosed(SPIT_ClientInterface* p_SPITClientInterface, string p_ProjectID) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_ProjectID = p_ProjectID;
|
||||
}
|
||||
~NotifyProjectClosed() {}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
m_SPITClientInterface->eventProjectClosed(m_ProjectID);
|
||||
}
|
||||
}
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
string m_ProjectID;
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
void parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer);
|
||||
void parseStartProjectTransfer(SPIT_Message::StartProjectTransfer* p_StartProjectTransfer);
|
||||
void parseEndProjectTransfer(SPIT_Message::EndProjectTransfer* p_EndProjectTransfer);
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyStartProjectTransfer : public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyStartProjectTransfer(SPIT_ClientInterface* p_SPITClientInterface) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
}
|
||||
~NotifyStartProjectTransfer() {}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
m_SPITClientInterface->eventStartProjectTransfer();
|
||||
}
|
||||
}
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
};
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyEndProjectTransfer : public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyEndProjectTransfer(SPIT_ClientInterface* p_SPITClientInterface) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
}
|
||||
~NotifyEndProjectTransfer() {}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
m_SPITClientInterface->eventEndProjectTransfer();
|
||||
}
|
||||
}
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
};
|
||||
|
||||
|
||||
// --------------- SPIT Types ---------------
|
||||
@@ -408,60 +271,6 @@ public:
|
||||
*/
|
||||
int removeSPITType(string p_SPITTypeID);
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyReportSPITType : public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyReportSPITType(bool p_Remote, bool p_New, SPIT_ClientInterface* p_SPITClientInterface, const SPITType& p_SPITType) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_Remote = p_Remote;
|
||||
m_New = p_New;
|
||||
m_SPITType = p_SPITType;
|
||||
}
|
||||
~NotifyReportSPITType() {}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
if (m_Remote == false) {
|
||||
m_SPITClientInterface->eventSPITType(m_New, m_SPITType);
|
||||
}
|
||||
else {
|
||||
m_SPITClientInterface->eventSPITTypeRemote(m_New, m_SPITType);
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
bool m_Remote;
|
||||
bool m_New;
|
||||
SPITType m_SPITType;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyRemoveSPITType : public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyRemoveSPITType(bool p_Remote, SPIT_ClientInterface* p_SPITClientInterface, const SPITType& p_SPITType) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_Remote = p_Remote;
|
||||
m_SPITType = p_SPITType;
|
||||
}
|
||||
~NotifyRemoveSPITType() {}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
if (m_Remote == false) {
|
||||
m_SPITClientInterface->eventSPITTypeRemoved(m_SPITType);
|
||||
}
|
||||
else {
|
||||
m_SPITClientInterface->eventSPITTypeRemoteRemoved(m_SPITType);
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
bool m_Remote;
|
||||
SPITType m_SPITType;
|
||||
};
|
||||
|
||||
|
||||
//--------------- SPIT Objects ---------------
|
||||
private:
|
||||
@@ -484,63 +293,6 @@ public:
|
||||
*/
|
||||
int removeSPITObject(string p_SPITObjectID);
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyReportSPITObject : public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyReportSPITObject(bool p_Remote, bool p_New, SPIT_ClientInterface* p_SPITClientInterface, const SPITType& p_SPITType, const SPITObject& p_SPITObject) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_Remote = p_Remote;
|
||||
m_New = p_New;
|
||||
m_SPITType = p_SPITType;
|
||||
m_SPITObject = p_SPITObject;
|
||||
}
|
||||
~NotifyReportSPITObject() {}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
if (m_Remote == false) {
|
||||
m_SPITClientInterface->eventSPITObject(m_New, m_SPITType, m_SPITObject);
|
||||
}
|
||||
else {
|
||||
m_SPITClientInterface->eventSPITObjectRemote(m_New, m_SPITType, m_SPITObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
bool m_Remote;
|
||||
bool m_New;
|
||||
SPITType m_SPITType;
|
||||
SPITObject m_SPITObject;
|
||||
};
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyRemoveSPITObject : public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyRemoveSPITObject(bool p_Remote, SPIT_ClientInterface* p_SPITClientInterface, const SPITType& p_SPITType, const SPITObject& p_SPITObject) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_Remote = p_Remote;
|
||||
m_SPITType = p_SPITType;
|
||||
m_SPITObject = p_SPITObject;
|
||||
}
|
||||
~NotifyRemoveSPITObject() {}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
if (m_Remote == false) {
|
||||
m_SPITClientInterface->eventSPITObjectRemoved(m_SPITType, m_SPITObject);
|
||||
}
|
||||
else {
|
||||
m_SPITClientInterface->eventSPITObjectRemoteRemoved(m_SPITType, m_SPITObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
bool m_Remote;
|
||||
SPITType m_SPITType;
|
||||
SPITObject m_SPITObject;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------- Play SPIT Objects ---------------
|
||||
private:
|
||||
@@ -548,91 +300,22 @@ private:
|
||||
void parsePlaySPITObject(SPIT_Message::PlaySPITObject* p_PlaySPITObject);
|
||||
void parsePlaySPITEnd(SPIT_Message::PlaySPITEnd* p_PlaySPITEnd);
|
||||
void parseReportPlayStatus(SPIT_Message::ReportPlayStatus* p_ReportPlayStatus);
|
||||
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyPlaySPITStart : public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyPlaySPITStart(SPIT_ClientInterface* p_SPITClientInterface, string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_IsRunning, long long p_TimeFrame) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_PlayerID = p_PlayerID;
|
||||
m_PlayerName = p_PlayerName;
|
||||
m_PlayerType = p_PlayerType;
|
||||
m_IsRunning = p_IsRunning;
|
||||
m_TimeFrames = p_TimeFrame;
|
||||
}
|
||||
~NotifyPlaySPITStart() {}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
m_SPITClientInterface->eventPlay(m_PlayerID, m_PlayerName, m_PlayerType, m_IsRunning, m_TimeFrames);
|
||||
}
|
||||
}
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
string m_PlayerID;
|
||||
string m_PlayerName;
|
||||
char m_PlayerType;
|
||||
bool m_IsRunning;
|
||||
long long m_TimeFrames;
|
||||
};
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyPlaySPITObject : public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyPlaySPITObject(bool p_Started, bool p_Stopped,
|
||||
SPIT_ClientInterface* p_SPITClientInterface, const SPITType& p_SPITType, const SPITObject& p_SPITObject, const SPITPlayer::PlayObject& p_PlayObject) {
|
||||
m_Started = p_Started;
|
||||
m_Stopped = p_Stopped;
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_SPITType = p_SPITType;
|
||||
m_SPITObject = p_SPITObject;
|
||||
m_PlayObject = p_PlayObject;
|
||||
}
|
||||
~NotifyPlaySPITObject() {}
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
m_SPITClientInterface->eventPlayObject(m_PlayObject.getPlayerID(), m_Started, m_Stopped, m_SPITType, m_SPITObject, m_PlayObject);
|
||||
}
|
||||
}
|
||||
private:
|
||||
bool m_Started;
|
||||
bool m_Stopped;
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
SPITObject m_SPITObject;
|
||||
SPITType m_SPITType;
|
||||
SPITPlayer::PlayObject m_PlayObject;
|
||||
|
||||
};
|
||||
public:
|
||||
/** Helper class to notify the SPITClientInterface/user's app*/
|
||||
class NotifyReportPlayStatus: public SPIT_Handler::Runnable {
|
||||
public:
|
||||
NotifyReportPlayStatus(SPIT_ClientInterface* p_SPITClientInterface, const SPITType& p_SPITType, const SPITObject& p_SPITObject,
|
||||
long long p_FrameInsideObject, int p_Value) {
|
||||
m_SPITClientInterface = p_SPITClientInterface;
|
||||
m_SPITObject = p_SPITObject;
|
||||
m_SPITType = p_SPITType;
|
||||
m_FrameInsideObject = p_FrameInsideObject;
|
||||
m_Value = p_Value;
|
||||
}
|
||||
~NotifyReportPlayStatus() {}
|
||||
private:
|
||||
SPIT_ClientInterface* m_SPITClientInterface;
|
||||
SPITObject m_SPITObject;
|
||||
SPITType m_SPITType;
|
||||
long long m_FrameInsideObject;
|
||||
int m_Value;
|
||||
public:
|
||||
void run() {
|
||||
if (m_SPITClientInterface != NULL) {
|
||||
m_SPITClientInterface->eventPlayRemoteObjectStatus(m_SPITType, m_SPITObject, m_FrameInsideObject, m_Value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
//--------- Remote ----------
|
||||
void sendRemoteObject(string p_SPITObjectID, int p_Valueppm = 0, char p_ValueFlag = 0x00);
|
||||
|
||||
private:
|
||||
static void processSocketTask(SPIT_Client & instance);
|
||||
fos::TaskT<SPIT_Client &>* sThread{};
|
||||
bool abortSearch{};
|
||||
bool sAnswered{};
|
||||
static fos::Semaphore sStartSad;
|
||||
SPITSocket * mSPITSocket;
|
||||
void answerWatchdog() {
|
||||
sAnswered = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /* SPIT_CLIENT_H */
|
||||
|
||||
Reference in New Issue
Block a user