/*! \file picloudtcp.h * \brief PICloud TCP transport */ /* PIP - Platform Independent Primitives PICloud TCP transport 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 . */ #ifndef PICLOUDTCP_H #define PICLOUDTCP_H #include "pip_cloud_export.h" #include "pistring.h" class PIEthernet; namespace PICloud { class PIP_CLOUD_EXPORT TCP { public: enum Version { Version_1 = 1, }; enum Role { Server = 1, Client = 2, }; enum Type { Invalid = 0, Connect = 1, Disconnect = 2, Data = 3, }; 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 sendDisconnected(PIEthernet * eth, uint client_id); void sendData(PIEthernet * eth, const PIByteArray & data); int sendData(PIEthernet * eth, const PIByteArray & data, uint client_id); PIPair parseHeader(PIByteArray & ba); PIByteArray parseData(PIByteArray & ba); PIPair parseDataServer(PIByteArray & ba); PIString parseConnect_d(PIByteArray & ba); uint parseConnect(PIByteArray & ba); uint parseDisconnect(PIByteArray & ba); private: struct Header { Header(); uchar version; // PICloud::Version uchar type; // PICloud::Type uchar role; // PICloud::Role }; Header header; PIString sname; }; } #endif // PICLOUDTCP_H