示例#1
0
void MOUL::NetMsgSDLState::read(DS::Stream* stream)
{
    NetMsgObject::read(stream);

    NetMsgStream blobStream;
    blobStream.read(stream);
    m_compression = blobStream.m_compression;
    uint8_t* sdl = new uint8_t[blobStream.m_stream.size()];
    memcpy(sdl, blobStream.m_stream.buffer(), blobStream.m_stream.size());
    m_sdlBlob = DS::Blob::Steal(sdl, blobStream.m_stream.size());

    m_isInitial = stream->read<bool>();
    m_persistOnServer = stream->read<bool>();
    m_isAvatar = stream->read<bool>();
}
示例#2
0
void MOUL::NetMsgSharedState::read(DS::Stream* stream)
{
    NetMsgObject::read(stream);

    NetMsgStream msgStream;
    msgStream.read(stream);
    m_compression = msgStream.m_compression;

    // Read the state
    uint16_t nameLen = msgStream.m_stream.read<uint16_t>();
    m_stateName = msgStream.m_stream.readString(nameLen, DS::e_StringUTF8);
    m_vars.resize(msgStream.m_stream.read<uint32_t>());
    m_serverMayDelete = msgStream.m_stream.readBool();

    for (size_t i=0; i<m_vars.size(); ++i)
        m_vars[i].read(&msgStream.m_stream);
    DS_DASSERT(msgStream.m_stream.atEof());

    m_lockRequest = stream->read<uint8_t>();
}
示例#3
0
void MOUL::NetMsgSharedState::write(DS::Stream* stream)
{
    NetMsgObject::write(stream);

    // Save the state to a stream
    NetMsgStream msgStream;
    msgStream.m_compression = m_compression;

    DS::StringBuffer<chr8_t> name = m_stateName.toUtf8();
    msgStream.m_stream.write<uint16_t>(name.length());
    msgStream.m_stream.writeBytes(name.data(), name.length());
    msgStream.m_stream.write<uint32_t>(m_vars.size());
    msgStream.m_stream.writeBool(m_serverMayDelete);

    for (size_t i=0; i<m_vars.size(); ++i)
        m_vars[i].write(&msgStream.m_stream);
    msgStream.m_stream.seek(0, SEEK_SET);
    msgStream.write(stream);

    stream->write<uint8_t>(m_lockRequest);
}