You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/simple_room_server/main.cpp
+8-4Lines changed: 8 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -123,6 +123,8 @@ struct PostInfo {
123
123
#definePUSH_TIMEOUT_BASE4000
124
124
#definePUSH_ACK_TIMEOUT_FACTOR2000
125
125
126
+
#definePOST_SYNC_DELAY_SECS6
127
+
126
128
#defineCLIENT_KEEP_ALIVE_SECS0// Now Disabled (was 128)
127
129
128
130
#defineREQ_TYPE_GET_STATUS0x01// same as _GET_STATS
@@ -861,13 +863,15 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
861
863
bool did_push = false;
862
864
if (client->pending_ack == 0 && client->last_activity != 0 && client->push_failures < 3) { // not already waiting for ACK, AND not evicted, AND retries not max
863
865
MESH_DEBUG_PRINTLN("loop - checking for client %02X", (uint32_t) client->id.pub_key[0]);
866
+
uint32_t now = getRTCClock()->getCurrentTime();
864
867
for (int k = 0, idx = next_post_idx; k < MAX_UNSYNCED_POSTS; k++) {
865
-
if (posts[idx].post_timestamp > client->sync_since// is new post for this Client?
866
-
&& !posts[idx].author.matches(client->id)) { // don't push posts to the author
868
+
auto p = &posts[idx];
869
+
if (now >= p->post_timestamp + POST_SYNC_DELAY_SECS && p->post_timestamp > client->sync_since// is new post for this Client?
870
+
&& !p->author.matches(client->id)) { // don't push posts to the author
867
871
// push this post to Client, then wait for ACK
868
-
pushPostToClient(client, posts[idx]);
872
+
pushPostToClient(client, *p);
869
873
did_push = true;
870
-
MESH_DEBUG_PRINTLN("loop - pushed to client %02X: %s", (uint32_t) client->id.pub_key[0], posts[idx].text);
874
+
MESH_DEBUG_PRINTLN("loop - pushed to client %02X: %s", (uint32_t) client->id.pub_key[0], p->text);
871
875
break;
872
876
}
873
877
idx = (idx + 1) % MAX_UNSYNCED_POSTS; // wrap to start of cyclic queue
0 commit comments