diff options
author | Aaron Seigo <aseigo@kde.org> | 2014-12-02 15:19:48 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2014-12-02 15:19:48 +0100 |
commit | 9c31df56c894892f20a30dc336cfe608b14679e0 (patch) | |
tree | 6b6d56d2aa714874daf914344f60ac8b89dbc8de /resource/listener.cpp | |
parent | 1ff1928f58f860d71210032d5f0a8e69eb482d2a (diff) | |
download | sink-9c31df56c894892f20a30dc336cfe608b14679e0.tar.gz sink-9c31df56c894892f20a30dc336cfe608b14679e0.zip |
consolidate command writing to avoid duplicating those 4 lines everywhere
Diffstat (limited to 'resource/listener.cpp')
-rw-r--r-- | resource/listener.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/resource/listener.cpp b/resource/listener.cpp index 038b3fa..4b3e4ff 100644 --- a/resource/listener.cpp +++ b/resource/listener.cpp | |||
@@ -173,11 +173,7 @@ void Listener::sendCurrentRevision(Client &client) | |||
173 | flatbuffers::FlatBufferBuilder fbb; | 173 | flatbuffers::FlatBufferBuilder fbb; |
174 | auto command = Akonadi::CreateRevisionUpdate(fbb, m_revision); | 174 | auto command = Akonadi::CreateRevisionUpdate(fbb, m_revision); |
175 | Akonadi::FinishRevisionUpdateBuffer(fbb, command); | 175 | Akonadi::FinishRevisionUpdateBuffer(fbb, command); |
176 | const int commandId = Commands::RevisionUpdateCommand; | 176 | Commands::write(client.socket, Commands::RevisionUpdateCommand, fbb); |
177 | const int dataSize = fbb.GetSize(); | ||
178 | client.socket->write((const char*)&commandId, sizeof(int)); | ||
179 | client.socket->write((const char*)&dataSize, sizeof(int)); | ||
180 | client.socket->write((const char*)fbb.GetBufferPointer(), dataSize); | ||
181 | } | 177 | } |
182 | 178 | ||
183 | void Listener::updateClientsWithRevision() | 179 | void Listener::updateClientsWithRevision() |
@@ -185,15 +181,12 @@ void Listener::updateClientsWithRevision() | |||
185 | flatbuffers::FlatBufferBuilder fbb; | 181 | flatbuffers::FlatBufferBuilder fbb; |
186 | auto command = Akonadi::CreateRevisionUpdate(fbb, m_revision); | 182 | auto command = Akonadi::CreateRevisionUpdate(fbb, m_revision); |
187 | Akonadi::FinishRevisionUpdateBuffer(fbb, command); | 183 | Akonadi::FinishRevisionUpdateBuffer(fbb, command); |
188 | const int commandId = Commands::RevisionUpdateCommand; | ||
189 | const int dataSize = fbb.GetSize(); | ||
190 | 184 | ||
191 | for (const Client &client: m_connections) { | 185 | for (const Client &client: m_connections) { |
192 | if (!client.socket || !client.socket->isValid()) { | 186 | if (!client.socket || !client.socket->isValid()) { |
193 | continue; | 187 | continue; |
194 | } | 188 | } |
195 | client.socket->write((const char*)&commandId, sizeof(int)); | 189 | |
196 | client.socket->write((const char*)&dataSize, sizeof(int)); | 190 | Commands::write(client.socket, Commands::RevisionUpdateCommand, fbb); |
197 | client.socket->write((const char*)fbb.GetBufferPointer(), dataSize); | ||
198 | } | 191 | } |
199 | } | 192 | } |