45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#ifndef DISPATCHERCLIENT_H
|
|
#define DISPATCHERCLIENT_H
|
|
|
|
#include "piethernet.h"
|
|
#include "picloudtcp.h"
|
|
#include "pistreampacker.h"
|
|
|
|
|
|
class DispatcherClient: public PIObject {
|
|
PIOBJECT(DispatcherClient)
|
|
public:
|
|
DispatcherClient(PIEthernet * eth_, int id);
|
|
~DispatcherClient();
|
|
void start();
|
|
void close();
|
|
void sendConnected(uint client_id);
|
|
void sendDisconnected(uint client_id);
|
|
void sendData(const PIByteArray & data);
|
|
void sendDataToClient(const PIByteArray & data, uint client_id);
|
|
void authorise(bool ok);
|
|
bool isAuthorised() const {return authorised;}
|
|
PICloud::TCP::Role role() const {return tcp.role();}
|
|
PIString address();
|
|
uint clientId() const {return client_id;}
|
|
EVENT1(disconnectEvent, DispatcherClient *, client)
|
|
EVENT2(registerServer, const PIByteArray &, sname, DispatcherClient *, client)
|
|
EVENT2(registerClient, const PIByteArray &, sname, DispatcherClient *, client)
|
|
EVENT1(dataReaded, PIByteArray &, ba)
|
|
EVENT2(dataReadedServer, uint, id, PIByteArray &, ba)
|
|
|
|
private:
|
|
EVENT_HANDLER1(void, readed, PIByteArray &, data);
|
|
EVENT_HANDLER1(void, disconnected, bool, withError);
|
|
|
|
PITimer disconnect_tm;
|
|
std::atomic_bool authorised;
|
|
PIEthernet * eth;
|
|
PIStreamPacker streampacker;
|
|
PICloud::TCP tcp;
|
|
uint client_id;
|
|
};
|
|
|
|
|
|
#endif // DISPATCHERCLIENT_H
|