2013-11-21 14:49:30 +01:00
|
|
|
#ifndef NETWORK_DEPENDENCIES_PROTOCOLS_H
|
|
|
|
#define NETWORK_DEPENDENCIES_PROTOCOLS_H
|
|
|
|
|
|
|
|
#include <string>
|
2013-11-21 13:40:52 +01:00
|
|
|
|
|
|
|
namespace Oyster
|
|
|
|
{
|
|
|
|
namespace Network
|
|
|
|
{
|
|
|
|
namespace Protocols
|
|
|
|
{
|
|
|
|
enum PackageType
|
|
|
|
{
|
|
|
|
package_type_header,
|
|
|
|
package_type_test,
|
|
|
|
package_type_input,
|
|
|
|
package_type_update_position
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ProtocolHeader
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
int packageType;
|
|
|
|
int clientID;
|
|
|
|
|
|
|
|
ProtocolHeader() { this->packageType = package_type_header; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ProtocolTest : public ProtocolHeader
|
|
|
|
{
|
|
|
|
std::string textMessage;
|
|
|
|
ProtocolTest() { this->packageType = package_type_test; }
|
|
|
|
};
|
2013-11-22 11:40:55 +01:00
|
|
|
|
|
|
|
class ProtocolSet
|
2013-11-22 09:17:07 +01:00
|
|
|
{
|
2013-11-22 11:40:55 +01:00
|
|
|
public:
|
2013-11-22 09:17:07 +01:00
|
|
|
PackageType t;
|
2013-11-22 11:40:55 +01:00
|
|
|
union
|
|
|
|
{
|
|
|
|
ProtocolHeader* pHeader;
|
|
|
|
ProtocolTest *pTest;
|
|
|
|
|
|
|
|
}Protocol;
|
|
|
|
|
|
|
|
void Release()
|
2013-11-22 09:17:07 +01:00
|
|
|
{
|
2013-11-22 11:40:55 +01:00
|
|
|
switch(t)
|
|
|
|
{
|
|
|
|
case package_type_header:
|
|
|
|
if(Protocol.pHeader)
|
|
|
|
{
|
|
|
|
delete Protocol.pHeader;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case package_type_test:
|
|
|
|
if(Protocol.pTest)
|
|
|
|
{
|
|
|
|
delete Protocol.pTest;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2013-11-21 13:40:52 +01:00
|
|
|
}
|
|
|
|
}
|
2013-11-21 14:49:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|