From 97b79eeb86eedee57630b8d29f6eeab08ccb02b0 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Sun, 30 Nov 2014 13:05:19 +0100 Subject: add flatbuffer support and use that for the handshake --- client/resourceaccess.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/resourceaccess.cpp b/client/resourceaccess.cpp index 2972316..b0a26e7 100644 --- a/client/resourceaccess.cpp +++ b/client/resourceaccess.cpp @@ -2,6 +2,7 @@ #include "common/console.h" #include "common/commands.h" +#include "common/commands/handshake_generated.h" #include #include @@ -67,12 +68,15 @@ void ResourceAccess::connected() Console::main()->log(QString("Connected: %1").arg(m_socket->fullServerName())); { - const QByteArray name = QString::number((long long)this).toLatin1(); + flatbuffers::FlatBufferBuilder fbb; + auto name = fbb.CreateString("Client PID: " + QString::number((long long)this).toLatin1() + "!"); + auto command = Toynadi::CreateHandshake(fbb, name); + Toynadi::FinishHandshakeBuffer(fbb, command); const int commandId = Commands::HandshakeCommand; - const int dataSize = name.size(); + const int dataSize = fbb.GetSize(); m_socket->write((const char*)&commandId, sizeof(int)); m_socket->write((const char*)&dataSize, sizeof(int)); - m_socket->write(name.data(), name.size()); + m_socket->write((const char*)fbb.GetBufferPointer(), dataSize); } emit ready(true); -- cgit v1.2.3