mirror of
https://github.com/libretro/Mesen.git
synced 2024-11-27 19:10:21 +00:00
e7e77ccfa7
Fixed exception throwing to be standard
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#pragma once
|
|
#include "stdafx.h"
|
|
#include "NetMessage.h"
|
|
|
|
class HandShakeMessage : public NetMessage
|
|
{
|
|
private:
|
|
const static int CurrentVersion = 1;
|
|
uint32_t _protocolVersion = CurrentVersion;
|
|
char* _playerName = nullptr;
|
|
uint32_t _playerNameLength = 0;
|
|
void* _avatarData = nullptr;
|
|
uint32_t _avatarSize = 0;
|
|
|
|
protected:
|
|
virtual void ProtectedStreamState()
|
|
{
|
|
Stream<uint32_t>(_protocolVersion);
|
|
StreamArray((void**)&_playerName, _playerNameLength);
|
|
StreamArray(&_avatarData, _avatarSize);
|
|
}
|
|
|
|
public:
|
|
HandShakeMessage(void* buffer, uint32_t length) : NetMessage(buffer, length) { }
|
|
HandShakeMessage(string playerName, uint8_t* avatarData, uint32_t avatarSize) : NetMessage(MessageType::HandShake)
|
|
{
|
|
_protocolVersion = 1;
|
|
CopyString(&_playerName, _playerNameLength, playerName);
|
|
_avatarSize = avatarSize;
|
|
_avatarData = avatarData;
|
|
}
|
|
|
|
string GetPlayerName()
|
|
{
|
|
return string(_playerName);
|
|
}
|
|
|
|
uint8_t* GetAvatarData()
|
|
{
|
|
return (uint8_t*)_avatarData;
|
|
}
|
|
|
|
uint32_t GetAvatarSize()
|
|
{
|
|
return _avatarSize;
|
|
}
|
|
|
|
bool IsValid()
|
|
{
|
|
return _protocolVersion == CurrentVersion;
|
|
}
|
|
};
|