picloud add server logics
This commit is contained in:
@@ -49,6 +49,7 @@ private:
|
||||
PIByteArray buff;
|
||||
PIMutex mutex_buff;
|
||||
PIConditionVariable cond_buff;
|
||||
std::atomic_bool is_connected;
|
||||
};
|
||||
|
||||
#endif // PICLOUDCLIENT_H
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define PICLOUDSERVER_H
|
||||
|
||||
#include "picloudbase.h"
|
||||
#include "piconditionvar.h"
|
||||
|
||||
|
||||
class PIP_CLOUD_EXPORT PICloudServer : public PIIODevice, private PICloudBase
|
||||
@@ -36,12 +37,22 @@ public:
|
||||
|
||||
class Client : public PIIODevice {
|
||||
PIIODEVICE(PICloudServer::Client)
|
||||
friend class PICloudServer;
|
||||
public:
|
||||
Client(PICloudServer * srv = nullptr);
|
||||
Client(PICloudServer * srv = nullptr, uint id = 0);
|
||||
protected:
|
||||
bool openDevice();
|
||||
bool closeDevice();
|
||||
int readDevice(void * read_to, int max_size);
|
||||
int writeDevice(const void * data, int max_size);
|
||||
|
||||
private:
|
||||
void pushBuffer(const PIByteArray & ba);
|
||||
PICloudServer * server;
|
||||
uint client_id;
|
||||
PIByteArray buff;
|
||||
PIMutex mutex_buff;
|
||||
PIConditionVariable cond_buff;
|
||||
};
|
||||
|
||||
void setServerName(const PIString & server_name);
|
||||
@@ -56,8 +67,11 @@ protected:
|
||||
|
||||
private:
|
||||
EVENT_HANDLER2(void, readed, uchar * , data, int, size);
|
||||
void clientDisconnect(uint client_id);
|
||||
int sendData(const PIByteArray & data, uint client_id);
|
||||
|
||||
PIVector<Client> clients;
|
||||
PIVector<Client *> clients;
|
||||
PIMap<uint, Client *> index_clients;
|
||||
};
|
||||
|
||||
#endif // PICLOUDSERVER_H
|
||||
|
||||
@@ -58,10 +58,15 @@ public:
|
||||
|
||||
void sendStart(PIEthernet * eth);
|
||||
void sendConnected(PIEthernet * eth, uint client_id);
|
||||
void sendDisconnected(PIEthernet * eth, uint client_id);
|
||||
void sendData(PIEthernet * eth, const PIByteArray & data);
|
||||
int sendData(PIEthernet * eth, const PIByteArray & data, uint client_id);
|
||||
PIPair<PICloud::TCP::Type, PICloud::TCP::Role> parseHeader(PIByteArray & ba);
|
||||
PIByteArray parseData(PIByteArray & ba);
|
||||
PIString parseConnect(PIByteArray & ba);
|
||||
PIPair<uint, PIByteArray> parseDataServer(PIByteArray & ba);
|
||||
PIString parseConnect_d(PIByteArray & ba);
|
||||
uint parseConnect(PIByteArray & ba);
|
||||
uint parseDisconnect(PIByteArray & ba);
|
||||
|
||||
private:
|
||||
struct Header {
|
||||
|
||||
Reference in New Issue
Block a user