RoboidControl-cpp/Participant.h
2025-01-02 11:53:46 +01:00

45 lines
1.0 KiB
C++

#pragma once
#include "Messages.h"
#if defined(_WIN32) || defined(_WIN64)
#include <winsock2.h>
#endif
namespace Passer {
namespace Control {
/// @brief A participant is device which can communicate with other participants
class Participant {
public:
char buffer[1024];
long publishInterval = 3000; // 3 seconds
unsigned char networkId = 0;
SOCKET sock;
sockaddr_in server_addr;
Participant(const char *ipAddress, int port);
virtual void Update(unsigned long currentTimeMs);
virtual bool SendBuffer(unsigned char bufferSize);
virtual bool PublishBuffer(unsigned char bufferSize);
bool Publish(IMessage msg);
void ReceiveData(unsigned char bufferSize);
protected:
long nextPublishMe = 0;
virtual void ProcessNetworkIdMsg(NetworkIdMsg msg);
virtual void ProcessInvestigateMsg(InvestigateMsg msg);
virtual void ProcessThingMsg(ThingMsg msg);
virtual void ProcessPoseMsg(PoseMsg msg);
virtual void ProcessCustomMsg(CustomMsg msg);
};
} // namespace Control
} // namespace Passer
using namespace Passer::Control;