18 #include "precompiled.h"
37 void Put(
const char*
UNUSED(name),
const u8* data,
size_t len)
103 m_Client(client), m_Player(player), m_Turn(turn), m_Data(scriptInterface.GetContext(), data)
127 std::istringstream stream(std::string(pos, pEnd));
153 std::stringstream stream;
154 stream <<
"CSimulationMessage { m_Client: " <<
m_Client <<
", m_Player: " <<
m_Player <<
", m_Turn: " <<
m_Turn <<
", m_Data: " << source <<
" }";
155 return CStr(stream.str());
166 m_Data(scriptInterface.GetContext(), data)
185 std::istringstream stream(std::string(pos, pEnd));
202 std::stringstream stream;
203 stream <<
"CGameSetupMessage { m_Data: " << source <<
" }";
204 return CStr(stream.str());
virtual CStr ToString() const
Returns a string representation for the message.
CBufferBinarySerializer(ScriptInterface &scriptInterface, u8 *buffer)
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
virtual CStr ToString() const
Returns a string representation for the message.
virtual size_t GetSerializedLength() const
Retrieves the size in bytes of the serialized message.
void Put(const char *name, const u8 *data, size_t len)
virtual const u8 * Deserialize(const u8 *pStart, const u8 *pEnd)
Deserializes the message from the specified buffer.
CLengthBinarySerializerImpl()
std::string utf8_from_wstring(const std::wstring &src, Status *err)
opposite of wstring_from_utf8
virtual u8 * Serialize(u8 *pBuffer) const
Serialize the message into the specified buffer parameter.
virtual void NumberU32_Unbounded(const char *name, uint32_t &out)
CLengthBinarySerializer(ScriptInterface &scriptInterface)
void ScriptVal(const char *name, jsval value)
Serialize a jsval.
virtual void ScriptVal(const char *name, jsval &out)
Deserialize a jsval, replacing 'out'.
ScriptInterface * m_ScriptInterface
CGameSetupMessage(ScriptInterface &scriptInterface)
virtual u8 * Serialize(u8 *pBuffer) const
Serialize the message into the specified buffer parameter.
virtual size_t GetSerializedLength() const
Retrieves the size in bytes of the serialized message.
CSimulationMessage(ScriptInterface &scriptInterface)
virtual const u8 * Deserialize(const u8 *pStart, const u8 *pEnd)
Deserializes the message from the specified buffer.
CBufferBinarySerializerImpl(u8 *buffer)
void NumberU32_Unbounded(const char *name, uint32_t value)
Serialize a number.
The base class for all network messages exchanged within the game.
ScriptInterface & m_ScriptInterface
virtual size_t GetSerializedLength() const
Retrieves the size in bytes of the serialized message.
CBufferBinarySerializerImpl m_Impl
jsval get() const
Returns the current value (or JSVAL_VOID if uninitialised).
Abstraction around a SpiderMonkey JSContext.
void NumberI32_Unbounded(const char *name, int32_t value)
Serialize a number.
Serializer instance that writes directly to a buffer (which must be long enough). ...
virtual u8 * Serialize(u8 *pBuffer) const
Serialize the message into the specified buffer parameter.
std::wstring ToString(jsval obj, bool pretty=false)
Serialize to a binary stream.
virtual const u8 * Deserialize(const u8 *pStart, const u8 *pEnd)
Deserializes the message from the specified buffer.
void Put(const char *name, const u8 *data, size_t len)
virtual void NumberI32_Unbounded(const char *name, int32_t &out)
Serializer instance that simply counts how many bytes would be written.