network: implemented BoardTileDataChanged event

Dieser Commit ist enthalten in:
Reinder Feenstra 2020-12-24 00:13:27 +01:00
Ursprung a3beec359f
Commit 7960258386
3 geänderte Dateien mit 22 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -491,6 +491,10 @@ void Session::writeObject(Message& message, const ObjectPtr& object)
outputKeyboard->outputIdChanged = std::bind(&Session::outputKeyboardOutputIdChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
outputKeyboard->outputValueChanged = std::bind(&Session::outputKeyboardOutputValueChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
}
else if(auto* board = dynamic_cast<Board*>(object.get()))
{
m_objectSignals.emplace(handle, board->tileDataChanged.connect(std::bind(&Session::boardTileDataChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
}
message.write(handle);
message.write(object->getClassId());
@ -789,3 +793,15 @@ void Session::outputKeyboardOutputValueChanged(OutputKeyboard& outputKeyboard, c
event->write(value);
m_client->sendMessage(std::move(event));
}
void Session::boardTileDataChanged(Board& board, const TileLocation& location, const TileDataLong& data)
{
auto event = Message::newEvent(Message::Command::BoardTileDataChanged);
event->write(m_handles.getHandle(board.shared_from_this()));
event->write(location);
if(data.isLong())
event->write(data);
else
event->write<TileData>(data);
m_client->sendMessage(std::move(event));
}

Datei anzeigen

@ -37,6 +37,9 @@ class AbstractProperty;
class AbstractAttribute;
class InputMonitor;
class OutputKeyboard;
class Board;
struct TileLocation;
struct TileDataLong;
class Session : public std::enable_shared_from_this<Session>
{
@ -68,6 +71,8 @@ class Session : public std::enable_shared_from_this<Session>
void outputKeyboardOutputIdChanged(OutputKeyboard& outputKeyboard, uint32_t address, std::string_view id);
void outputKeyboardOutputValueChanged(OutputKeyboard& outputKeyboard, uint32_t address, TriState value);
void boardTileDataChanged(Board& board, const TileLocation& location, const TileDataLong& data);
public:
Session(const std::shared_ptr<Client>& client);

Datei anzeigen

@ -81,6 +81,7 @@ class Message
OutputKeyboardOutputValueChanged = 36,
BoardGetTileData = 37,
BoardTileDataChanged = 38,
Discover = 255,
};