This commit is contained in:
2025-11-15 13:50:18 +01:00
parent 331258692b
commit 7edc57784c
6 changed files with 470 additions and 1004 deletions
+57 -67
View File
@@ -57,7 +57,10 @@ class SProcessor {
};
struct InternalCallbacks {
function<int(SType &sType)> sendSpitTypeInternal;
function<void(int ms)> delay;
function<int(Message::OPPart &msg)> sendMessage;
function<int(SType &sType)> sendTypeInternal;
function<int(SObject *sObject)> sendObjectInternal;
};
// //------ PlayerType ------
@@ -99,20 +102,20 @@ class SProcessor {
// string mClientProjectName;
// uint8_t mMessageNumberSend{1};
// int mMessageNumberReceived{-1}; // set to -1 because the first received message will set the number (1..255)
// vector<unique_ptr<Message>> mOvertakingMessages;
uint8_t mMessageNumberSend{1};
int mMessageNumberReceived{-1}; // set to -1 because the first received message will set the number (1..255)
vector<unique_ptr<Message>> mOvertakingMessages;
// // Server's info filled by parseConnectAnswer
// string mServerID{};
string mServerID{};
// string mServerName{};
// string mServerComputerName{};
// int mServerStepTime{-1};
// //--- Server Project ---
// string mServerProjectID;
// string mServerProjectName;
// int mServerFramesPerSecond;
string mServerProjectID;
string mServerProjectName;
int mServerFramesPerSecond;
// public:
// /** The ID of the client.<br>Every client instance should set an unique id*/
@@ -153,9 +156,9 @@ class SProcessor {
// private:
// // Reconnect to the server when connection is lost see eventConnectionStatus and eventServerDetected
// bool _doReconnect{}; // true = on eventServerDetected connect to the server identified by mServerID
// public:
// std::vector<char> createMessage(Message::OPPart & spitMessageOPPart);
// void checkParseMessageData(vector<char> data);
public:
std::vector<char> createMessage(Message::OPPart & spitMessageOPPart);
void checkParseMessageData(vector<char> data);
// //--------------- ServerAutoDetection SAD ---------------
// public:
@@ -191,7 +194,7 @@ class SProcessor {
// private:
// void disconnectInternal(Connection cause);
// void resetMessageNumberReceived();
// void parseMessage(Message& message);
void parseMessage(Message& message);
// void addOvertakingMessage(unique_ptr<Message> message);
// void parseConnectAnswer(Message::ConnectAnswer &message);
// void parseDisconnect(Message::Disconnect &message);
@@ -205,24 +208,23 @@ class SProcessor {
// void eventWatchdogLost();
// //--------------- SPIT Project ---------------
// private:
// void parseReportProject(Message::ReportProject &message);
// void parseCloseProject(Message::CloseProject &message);
public: // tood remove
void parseReportProject(Message::ReportProject &message);
void parseCloseProject(Message::CloseProject &message);
// public:
// /** Returns the SPITServer's project ID - may be the same as the project's name*/
// string getServerProjectID();
// /** Returns the SPITServer's project name*/
// 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:
/** Returns the SPITServer's project ID - may be the same as the project's name*/
string getServerProjectID();
/** Returns the SPITServer's project name*/
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();
// private:
// void parseRequestProjectTransfer(Message::RequestProjectTransfer &message);
// void parseStartProjectTransfer(Message::StartProjectTransfer &message);
// void parseEndProjectTransfer(Message::EndProjectTransfer &message);
// public:
// // static void sendProject(SClient *p_PtrSProcessor);
public: // todo remove
void parseRequestProjectTransfer(Message::RequestProjectTransfer &message);
void parseStartProjectTransfer(Message::StartProjectTransfer &message);
void parseEndProjectTransfer(Message::EndProjectTransfer &message);
// // --------------- SPIT Types ---------------
// public:
@@ -255,55 +257,43 @@ class SProcessor {
private:
public: // @todo delete
void parseReportType(Message::ReportType &message);
// void parseRemoveSPITType(Message::RemoveType &message);
// int sendSPITTypeInternal(SType &sType);
void parseRemoveType(Message::RemoveType &message);
// public:
// /**
// * If a client wants to change a SPITType, he should send it to the server.<br>
// * If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the change.<br>
// * @param spitypeID the id of the SPITType to remove.
// * @return 0 = is sended, -1 = is not sended
// */
// bool changeSPITType(SType *spitType);
// /**
// * If a client wants to remove a SPITType, he should send it to the server.<br>
// * If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the deletion.<br>
// * @param spitypeID the id of the SPITType to remove.
// * @return 0 = is sended, -1 = is not sended
// */
// int removeSPITType(string spitypeID);
public:
/**
* If a client wants to change a SPITType, he should send it to the server.<br>
* If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the change.<br>
* @param spitypeID the id of the SPITType to remove.
* @return 0 = is sended, -1 = is not sended
*/
bool changeType(SType *spitType);
/**
* If a client wants to remove a SPITType, he should send it to the server.<br>
* If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the deletion.<br>
* @param spitypeID the id of the SPITType to remove.
* @return 0 = is sended, -1 = is not sended
*/
int removeType(string spitypeID);
// public:
// //--------------- SPIT Objects ---------------
// private:
// void parseReportSPITObject(Message::ReportObject &message);
// void parseRemoveSPITObject(Message::RemoveObject &message);
public:
void parseReportObject(Message::ReportObject &message);
void parseRemoveObject(Message::RemoveObject &message);
// int sendSPITObjectInternal(SObject *ptrObject);
// public:
// /**
// * When the client changes a SPITObject (normally the client should not do this), then it should send the changes to the SPITServer.<br>
// * The SPITServer may discard the changes and an eventSPITObject occurs.<br>
// * @param spitObject the pointer to the changed SPITObject.
// * @return 0 = sended, -1 = not sended
// */
// bool changeSPITObject(SObject *spitObject);
// /**
// * When the client removes a SPITObject (normally the client should not do this), then he should send it to the SPITServer.<br>
// * The SPITServer may discard the deletion and an eventSPITObject occurs.<br>
// * @param objectID the id of the SPITObject to remove.
// * @return 0 = sended, -1 = not sended
// */
// int removeSPITObject(string objectID);
int removeObject(string objectID);
// public:
// //--------------- Play SPIT Objects ---------------
// private:
// void parsePlaySPITStart(Message::PlayStart &message);
// void parsePlaySPITObject(Message::PlayObject &message);
// void parsePlaySPITEnd(Message::PlayEnd &message);
// void parseReportPlayStatus(Message::ReportPlayStatus &message);
public:
void parsePlayStart(Message::PlayStart &message);
void parsePlayObject(Message::PlayObject &message);
void parsePlayEnd(Message::PlayEnd &message);
void parseReportPlayStatus(Message::ReportPlayStatus &message);
// public:
// //--------- Remote ----------
@@ -316,9 +306,9 @@ public: // @todo delete
// sAnswered = true;
// }
// SpitRepo<SObject> mSpitObjects;
// SpitRepo<SObject> mRemoteSpitObjects;
public: // @todo remove
public: // @todo remove
SpitRepo<SObject> mSpitObjects;
SpitRepo<SObject> mRemoteSpitObjects;
SpitRepo<SType> mSpitTypes;
SpitRepo<SType> mRemoteSpitTypes;
};