2014-07-09 23:05:07 +00:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "NetMessage.h"
|
|
|
|
|
|
|
|
class HandShakeMessage : public NetMessage
|
|
|
|
{
|
|
|
|
private:
|
2015-07-02 03:17:14 +00:00
|
|
|
const static int CurrentVersion = 1;
|
|
|
|
uint32_t _protocolVersion = CurrentVersion;
|
|
|
|
wchar_t *_playerName = nullptr;
|
|
|
|
uint32_t _playerNameLength = 0;
|
|
|
|
void* _avatarData = nullptr;
|
|
|
|
uint32_t _avatarSize = 0;
|
2014-07-09 23:05:07 +00:00
|
|
|
|
|
|
|
protected:
|
2015-07-02 03:17:14 +00:00
|
|
|
virtual void ProtectedStreamState()
|
2014-07-09 23:05:07 +00:00
|
|
|
{
|
2015-07-02 03:17:14 +00:00
|
|
|
Stream<uint32_t>(_protocolVersion);
|
|
|
|
StreamArray((void**)&_playerName, _playerNameLength);
|
|
|
|
StreamArray(&_avatarData, _avatarSize);
|
2014-07-09 23:05:07 +00:00
|
|
|
}
|
|
|
|
|
2015-07-02 03:17:14 +00:00
|
|
|
public:
|
|
|
|
HandShakeMessage(void* buffer, uint32_t length) : NetMessage(buffer, length) { }
|
|
|
|
HandShakeMessage(wstring playerName, uint8_t* avatarData, uint32_t avatarSize) : NetMessage(MessageType::HandShake)
|
2014-07-09 23:05:07 +00:00
|
|
|
{
|
2015-07-02 03:17:14 +00:00
|
|
|
_protocolVersion = 1;
|
|
|
|
CopyString(&_playerName, _playerNameLength, playerName);
|
|
|
|
_avatarSize = avatarSize;
|
|
|
|
_avatarData = avatarData;
|
|
|
|
}
|
|
|
|
|
|
|
|
wstring GetPlayerName()
|
|
|
|
{
|
|
|
|
return wstring(_playerName);
|
2014-07-09 23:05:07 +00:00
|
|
|
}
|
|
|
|
|
2015-07-02 03:17:14 +00:00
|
|
|
uint8_t* GetAvatarData()
|
2014-07-09 23:05:07 +00:00
|
|
|
{
|
2015-07-02 03:17:14 +00:00
|
|
|
return (uint8_t*)_avatarData;
|
2014-07-09 23:05:07 +00:00
|
|
|
}
|
|
|
|
|
2015-07-02 03:17:14 +00:00
|
|
|
uint32_t GetAvatarSize()
|
2014-07-09 23:05:07 +00:00
|
|
|
{
|
2015-07-02 03:17:14 +00:00
|
|
|
return _avatarSize;
|
2014-07-09 23:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsValid()
|
|
|
|
{
|
2015-07-02 03:17:14 +00:00
|
|
|
return _protocolVersion == CurrentVersion;
|
2014-07-09 23:05:07 +00:00
|
|
|
}
|
|
|
|
};
|