PICloud small patches
This commit is contained in:
@@ -28,11 +28,13 @@
|
||||
#include "pistreampacker.h"
|
||||
|
||||
|
||||
class PICloudBase
|
||||
class PIP_CLOUD_EXPORT PICloudBase
|
||||
{
|
||||
public:
|
||||
PICloudBase();
|
||||
|
||||
PIString serverName() const;
|
||||
|
||||
protected:
|
||||
PIEthernet eth;
|
||||
PIStreamPacker streampacker;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "piconditionvar.h"
|
||||
|
||||
|
||||
class PIP_CLOUD_EXPORT PICloudClient : public PIIODevice, private PICloudBase
|
||||
class PIP_CLOUD_EXPORT PICloudClient: public PIIODevice, public PICloudBase
|
||||
{
|
||||
PIIODEVICE(PICloudClient)
|
||||
public:
|
||||
@@ -39,6 +39,9 @@ public:
|
||||
void setKeepConnection(bool on);
|
||||
bool isConnected() const {return is_connected;}
|
||||
|
||||
EVENT(connected)
|
||||
EVENT(disconnected)
|
||||
|
||||
protected:
|
||||
bool openDevice();
|
||||
bool closeDevice();
|
||||
@@ -46,7 +49,6 @@ protected:
|
||||
int writeDevice(const void * data, int size);
|
||||
DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Reliable;}
|
||||
|
||||
|
||||
private:
|
||||
EVENT_HANDLER1(void, _readed, PIByteArray &, data);
|
||||
PIByteArray buff;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "piconditionvar.h"
|
||||
|
||||
|
||||
class PIP_CLOUD_EXPORT PICloudServer : public PIIODevice, private PICloudBase
|
||||
class PIP_CLOUD_EXPORT PICloudServer: public PIIODevice, public PICloudBase
|
||||
{
|
||||
PIIODEVICE(PICloudServer)
|
||||
public:
|
||||
|
||||
@@ -57,7 +57,8 @@ public:
|
||||
TCP(PIStreamPacker * s);
|
||||
void setRole(Role r);
|
||||
Role role() const {return (Role)header.role;}
|
||||
void setServerName(const PIString & server_name);
|
||||
void setServerName(const PIString & server_name_);
|
||||
PIString serverName() const;
|
||||
|
||||
void sendStart();
|
||||
void sendConnected(uint client_id);
|
||||
@@ -81,6 +82,7 @@ private:
|
||||
|
||||
Header header;
|
||||
PIByteArray suuid;
|
||||
PIString server_name;
|
||||
PIStreamPacker * streampacker;
|
||||
};
|
||||
|
||||
|
||||
@@ -389,6 +389,12 @@ bool PIIODevice::close() {
|
||||
return !opened_;
|
||||
}
|
||||
|
||||
int PIIODevice::write(PIByteArray data) {
|
||||
if (isOpened())
|
||||
return writeDevice(data.data(), data.size_s());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
bool PIIODevice::configure(const PIString & config_file, const PIString & section, bool parent_section) {
|
||||
PIConfig conf(config_file, PIIODevice::ReadOnly);
|
||||
|
||||
@@ -263,7 +263,7 @@ public:
|
||||
bool open(DeviceMode _mode);
|
||||
EVENT_HANDLER2(bool, open, const PIString &, _path, DeviceMode, _mode);
|
||||
EVENT_HANDLER(bool, close);
|
||||
EVENT_HANDLER1(int, write, PIByteArray, data) {return writeDevice(data.data(), data.size_s());}
|
||||
EVENT_HANDLER1(int, write, PIByteArray, data);
|
||||
|
||||
EVENT_VHANDLER(void, flush) {;}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user