PICloud connect/disconnect
This commit is contained in:
40
libs/main/cloud/picloudbase.h
Normal file
40
libs/main/cloud/picloudbase.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*! \file picloudbase.h
|
||||
* \brief PICloud Base - Base class for PICloudClient and PICloud Server
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PICloud Base - Base class for PICloudClient and PICloud Server
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PICLOUDBASE_H
|
||||
#define PICLOUDBASE_H
|
||||
|
||||
#include "picloudtcp.h"
|
||||
#include "piethernet.h"
|
||||
|
||||
|
||||
class PICloudBase
|
||||
{
|
||||
public:
|
||||
PICloudBase();
|
||||
|
||||
protected:
|
||||
PIEthernet eth;
|
||||
PICloud::TCP tcp;
|
||||
};
|
||||
|
||||
#endif // PICLOUDBASE_H
|
||||
@@ -23,11 +23,11 @@
|
||||
#ifndef PICLOUDCLIENT_H
|
||||
#define PICLOUDCLIENT_H
|
||||
|
||||
#include "picloudtcp.h"
|
||||
#include "piethernet.h"
|
||||
#include "picloudbase.h"
|
||||
#include "piconditionvar.h"
|
||||
|
||||
|
||||
class PIP_CLOUD_EXPORT PICloudClient : public PIIODevice
|
||||
class PIP_CLOUD_EXPORT PICloudClient : public PIIODevice, private PICloudBase
|
||||
{
|
||||
PIIODEVICE(PICloudClient)
|
||||
public:
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
virtual ~PICloudClient();
|
||||
|
||||
void setServerName(const PIString & server_name);
|
||||
void setKeepConnection(bool on);
|
||||
|
||||
protected:
|
||||
bool openDevice();
|
||||
@@ -45,9 +46,9 @@ protected:
|
||||
|
||||
private:
|
||||
EVENT_HANDLER2(void, readed, uchar * , data, int, size);
|
||||
|
||||
PIEthernet eth;
|
||||
PICloud::TCP tcp;
|
||||
PIByteArray buff;
|
||||
PIMutex mutex_buff;
|
||||
PIConditionVariable cond_buff;
|
||||
};
|
||||
|
||||
#endif // PICLOUDCLIENT_H
|
||||
|
||||
@@ -23,11 +23,10 @@
|
||||
#ifndef PICLOUDSERVER_H
|
||||
#define PICLOUDSERVER_H
|
||||
|
||||
#include "picloudtcp.h"
|
||||
#include "piethernet.h"
|
||||
#include "picloudbase.h"
|
||||
|
||||
|
||||
class PIP_CLOUD_EXPORT PICloudServer : public PIIODevice
|
||||
class PIP_CLOUD_EXPORT PICloudServer : public PIIODevice, private PICloudBase
|
||||
{
|
||||
PIIODEVICE(PICloudServer)
|
||||
public:
|
||||
@@ -45,6 +44,8 @@ public:
|
||||
PICloudServer * server;
|
||||
};
|
||||
|
||||
void setServerName(const PIString & server_name);
|
||||
|
||||
EVENT1(newConnection, PICloudServer::Client * , client)
|
||||
|
||||
protected:
|
||||
@@ -56,9 +57,7 @@ protected:
|
||||
private:
|
||||
EVENT_HANDLER2(void, readed, uchar * , data, int, size);
|
||||
|
||||
PIEthernet eth;
|
||||
PIVector<Client> clients;
|
||||
PICloud::TCP tcp;
|
||||
};
|
||||
|
||||
#endif // PICLOUDSERVER_H
|
||||
|
||||
@@ -53,9 +53,12 @@ public:
|
||||
|
||||
TCP();
|
||||
void setRole(Role r);
|
||||
Role role() const {return (Role)header.role;}
|
||||
void setServerName(const PIString & server_name);
|
||||
|
||||
void sendStart(PIEthernet * eth);
|
||||
void sendConnected(PIEthernet * eth, uint client_id);
|
||||
void sendData(PIEthernet * eth, const PIByteArray & data);
|
||||
PIPair<PICloud::TCP::Type, PICloud::TCP::Role> parseHeader(PIByteArray & ba);
|
||||
PIByteArray parseData(PIByteArray & ba);
|
||||
PIString parseConnect(PIByteArray & ba);
|
||||
|
||||
Reference in New Issue
Block a user