Danbias/Code/Network/NetworkAPI/Translator.h

62 lines
1.4 KiB
C
Raw Normal View History

#ifndef NETWORK_DEPENDENCIES_TRANSLATOR_H
#define NETWORK_DEPENDENCIES_TRANSLATOR_H
//////////////////////////////////
// Created by Sam Svensson 2013 //
// ----------------------------//
// Packs our dynamic protocols //
//////////////////////////////////
/*
It packs a header in front of the actual message.
Header looks like this:
- Size of the entire package
- String containing all the types of data that is packed in the package.
*/
/*
Possible optimizing:
If there are several of the same type of data in a row,
we can instead of saving a character for each type we can instead save a number and the character.
Example:
If we are packing 100 floats.
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF..."
Instead of that we can do this:
"100F"
*/
2014-01-28 09:00:02 +01:00
#include "NetworkAPI_Preprocessor.h"
namespace Oyster
{
namespace Network
{
extern "C"
{
class OysterByte;
class CustomNetProtocol;
2014-01-28 09:00:02 +01:00
class NET_API_EXPORT Translator
{
public:
Translator ();
~Translator();
2013-12-12 12:17:39 +01:00
Translator(const Translator& obj);
const Translator& operator=(const Translator& obj);
2013-12-13 23:47:16 +01:00
void Pack(OysterByte &bytes, CustomNetProtocol& protocol);
//Returns false if it discovers any faulty stuff with the package.
2013-12-13 23:47:16 +01:00
bool Unpack(CustomNetProtocol& protocol, OysterByte &bytes);
private:
struct PrivateData;
PrivateData* privateData;
};
}
}
}
#endif