RoboidControl-cpp/Participant.h
2025-01-02 12:48:14 +01:00

46 lines
1.1 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;
const char *name = "Participant";
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(ClientMsg msg);
void ReceiveData(unsigned char bufferSize);
protected:
unsigned 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;