Browse Source

* room server login response now includes unsynced posts counter

pull/205/head
Scott Powell 1 year ago
parent
commit
b17196acb4
  1. 13
      examples/simple_room_server/main.cpp

13
examples/simple_room_server/main.cpp

@ -232,6 +232,17 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
} }
} }
uint8_t getUnsyncedCount(ClientInfo* client) {
uint8_t count = 0;
for (int k = 0; k < MAX_UNSYNCED_POSTS; k++) {
if (posts[k].post_timestamp > client->sync_since // is new post for this Client?
&& !posts[k].author.matches(client->id)) { // don't push posts to the author
count++;
}
}
return count;
}
bool processAck(const uint8_t *data) { bool processAck(const uint8_t *data) {
for (int i = 0; i < num_clients; i++) { for (int i = 0; i < num_clients; i++) {
auto client = &known_clients[i]; auto client = &known_clients[i];
@ -398,7 +409,7 @@ protected:
reply_data[4] = RESP_SERVER_LOGIN_OK; reply_data[4] = RESP_SERVER_LOGIN_OK;
reply_data[5] = (CLIENT_KEEP_ALIVE_SECS >> 4); // NEW: recommended keep-alive interval (secs / 16) reply_data[5] = (CLIENT_KEEP_ALIVE_SECS >> 4); // NEW: recommended keep-alive interval (secs / 16)
reply_data[6] = (perm == RoomPermission::ADMIN ? 1 : (perm == RoomPermission::GUEST ? 0 : 2)); reply_data[6] = (perm == RoomPermission::ADMIN ? 1 : (perm == RoomPermission::GUEST ? 0 : 2));
reply_data[7] = 0; // FUTURE: reserved reply_data[7] = getUnsyncedCount(client); // NEW
memcpy(&reply_data[8], "OK", 2); // REVISIT: not really needed memcpy(&reply_data[8], "OK", 2); // REVISIT: not really needed
next_push = futureMillis(PUSH_NOTIFY_DELAY_MILLIS); // delay next push, give RESPONSE packet time to arrive first next_push = futureMillis(PUSH_NOTIFY_DELAY_MILLIS); // delay next push, give RESPONSE packet time to arrive first

Loading…
Cancel
Save