Skip to content

Commit b17196a

Browse files
author
Scott Powell
committed
* room server login response now includes unsynced posts counter
1 parent 1f1d39d commit b17196a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

examples/simple_room_server/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,17 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
232232
}
233233
}
234234

235+
uint8_t getUnsyncedCount(ClientInfo* client) {
236+
uint8_t count = 0;
237+
for (int k = 0; k < MAX_UNSYNCED_POSTS; k++) {
238+
if (posts[k].post_timestamp > client->sync_since // is new post for this Client?
239+
&& !posts[k].author.matches(client->id)) { // don't push posts to the author
240+
count++;
241+
}
242+
}
243+
return count;
244+
}
245+
235246
bool processAck(const uint8_t *data) {
236247
for (int i = 0; i < num_clients; i++) {
237248
auto client = &known_clients[i];
@@ -398,7 +409,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
398409
reply_data[4] = RESP_SERVER_LOGIN_OK;
399410
reply_data[5] = (CLIENT_KEEP_ALIVE_SECS >> 4); // NEW: recommended keep-alive interval (secs / 16)
400411
reply_data[6] = (perm == RoomPermission::ADMIN ? 1 : (perm == RoomPermission::GUEST ? 0 : 2));
401-
reply_data[7] = 0; // FUTURE: reserved
412+
reply_data[7] = getUnsyncedCount(client); // NEW
402413
memcpy(&reply_data[8], "OK", 2); // REVISIT: not really needed
403414

404415
next_push = futureMillis(PUSH_NOTIFY_DELAY_MILLIS); // delay next push, give RESPONSE packet time to arrive first

0 commit comments

Comments
 (0)