Commit b19bd718 authored by Hubert Denkmair's avatar Hubert Denkmair
Browse files

send gameinfo frames to websocket clients for testing

parent 658c7ab1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -43,6 +43,11 @@ bool TcpProtocol::Read(int socket)
	return true;
}

const MsgPackProtocol::GameInfoMessage &TcpProtocol::GetGameInfo() const
{
	return _gameInfo;
}

void TcpProtocol::OnMessageReceived(const char* data, size_t count)
{
	msgpack::object_handle obj;
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ class TcpProtocol
		void SetFrameCompleteCallback(FrameCompleteCallback callback);
		bool Read(int socket);

		const MsgPackProtocol::GameInfoMessage& GetGameInfo() const;

	private:
		static constexpr const size_t SPATIAL_MAP_TILES_X = 128;
		static constexpr const size_t SPATIAL_MAP_TILES_Y = 128;
+5 −1
Original line number Diff line number Diff line
#include "WebsocketConnection.h"
#include "TcpProtocol.h"
#include "MsgPackProtocol.h"

WebsocketConnection::WebsocketConnection(int socket, WebsocketServer::connection_ptr websocket)
	: _socket(socket), _websocket(websocket)
@@ -17,5 +19,7 @@ void WebsocketConnection::DataReceived(const char *data, size_t count)

void WebsocketConnection::FrameComplete(uint64_t frame_id, const TcpProtocol &proto)
{

	msgpack::sbuffer buf;
	msgpack::pack(buf, proto.GetGameInfo());
	_websocket->send(buf.data(), buf.size());
}