mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
protobuf client->server communication almost working
This commit is contained in:
parent
4eb9dfc5bf
commit
314f17091d
96 changed files with 1633 additions and 860 deletions
|
|
@ -13,9 +13,13 @@
|
|||
#include "tab_userlists.h"
|
||||
#include "userlist.h"
|
||||
#include "abstractclient.h"
|
||||
#include "protocol_items.h"
|
||||
#include "chatview.h"
|
||||
#include "gameselector.h"
|
||||
#include "protocol_items.h"
|
||||
|
||||
#include "pending_command.h"
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include "pb/room_commands.pb.h"
|
||||
|
||||
TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, const QString &_ownName, ServerInfo_Room *info)
|
||||
: Tab(_tabSupervisor), client(_client), roomId(info->getRoomId()), roomName(info->getName()), ownName(_ownName)
|
||||
|
|
@ -108,9 +112,12 @@ void TabRoom::sendMessage()
|
|||
if (sayEdit->text().isEmpty())
|
||||
return;
|
||||
|
||||
Command_RoomSay *cmd = new Command_RoomSay(roomId, sayEdit->text());
|
||||
connect(cmd, SIGNAL(finished(ProtocolResponse *)), this, SLOT(sayFinished(ProtocolResponse *)));
|
||||
client->sendCommand(cmd);
|
||||
Command_RoomSay cmd;
|
||||
cmd.set_message(sayEdit->text().toStdString());
|
||||
|
||||
PendingCommand *pend = prepareRoomCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(sayFinished(ProtocolResponse *)));
|
||||
sendRoomCommand(pend);
|
||||
sayEdit->clear();
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +129,7 @@ void TabRoom::sayFinished(ProtocolResponse *response)
|
|||
|
||||
void TabRoom::actLeaveRoom()
|
||||
{
|
||||
client->sendCommand(new Command_LeaveRoom(roomId));
|
||||
sendRoomCommand(prepareRoomCommand(Command_LeaveRoom()));
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
|
|
@ -161,3 +168,17 @@ void TabRoom::processSayEvent(Event_RoomSay *event)
|
|||
chatView->appendMessage(event->getPlayerName(), event->getMessage());
|
||||
emit userEvent(false);
|
||||
}
|
||||
|
||||
PendingCommand *TabRoom::prepareRoomCommand(const ::google::protobuf::Message &cmd)
|
||||
{
|
||||
CommandContainer cont;
|
||||
RoomCommand *c = cont.add_room_command();
|
||||
cont.set_room_id(roomId);
|
||||
c->GetReflection()->MutableMessage(c, cmd.GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(cmd);
|
||||
return new PendingCommand(cont);
|
||||
}
|
||||
|
||||
void TabRoom::sendRoomCommand(PendingCommand *pend)
|
||||
{
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue