Просмотр исходного кода

* SERVER_RESPONSE_DELAY now applied to: login responses, companion telemetry responses

Scott Powell 1 год назад
Родитель
Сommit
5d15a68d0d
3 измененных файлов с 13 добавлено и 9 удалено
  1. 3 3
      examples/simple_repeater/main.cpp
  2. 3 3
      examples/simple_room_server/main.cpp
  3. 7 3
      src/helpers/BaseChatMesh.cpp

+ 3 - 3
examples/simple_repeater/main.cpp

@@ -383,14 +383,14 @@ protected:
         // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
         // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
         mesh::Packet* path = createPathReturn(sender, client->secret, packet->path, packet->path_len,
         mesh::Packet* path = createPathReturn(sender, client->secret, packet->path, packet->path_len,
                                               PAYLOAD_TYPE_RESPONSE, reply_data, 12);
                                               PAYLOAD_TYPE_RESPONSE, reply_data, 12);
-        if (path) sendFlood(path);
+        if (path) sendFlood(path, SERVER_RESPONSE_DELAY);
       } else {
       } else {
         mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, client->secret, reply_data, 12);
         mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, client->secret, reply_data, 12);
         if (reply) {
         if (reply) {
           if (client->out_path_len >= 0) {  // we have an out_path, so send DIRECT
           if (client->out_path_len >= 0) {  // we have an out_path, so send DIRECT
-            sendDirect(reply, client->out_path, client->out_path_len);
+            sendDirect(reply, client->out_path, client->out_path_len, SERVER_RESPONSE_DELAY);
           } else {
           } else {
-            sendFlood(reply);
+            sendFlood(reply, SERVER_RESPONSE_DELAY);
           }
           }
         }
         }
       }
       }

+ 3 - 3
examples/simple_room_server/main.cpp

@@ -479,14 +479,14 @@ protected:
         // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
         // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
         mesh::Packet* path = createPathReturn(sender, client->secret, packet->path, packet->path_len,
         mesh::Packet* path = createPathReturn(sender, client->secret, packet->path, packet->path_len,
                                               PAYLOAD_TYPE_RESPONSE, reply_data, 8 + 2);
                                               PAYLOAD_TYPE_RESPONSE, reply_data, 8 + 2);
-        if (path) sendFlood(path);
+        if (path) sendFlood(path, SERVER_RESPONSE_DELAY);
       } else {
       } else {
         mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, client->secret, reply_data, 8 + 2);
         mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, client->secret, reply_data, 8 + 2);
         if (reply) {
         if (reply) {
           if (client->out_path_len >= 0) {  // we have an out_path, so send DIRECT
           if (client->out_path_len >= 0) {  // we have an out_path, so send DIRECT
-            sendDirect(reply, client->out_path, client->out_path_len);
+            sendDirect(reply, client->out_path, client->out_path_len, SERVER_RESPONSE_DELAY);
           } else {
           } else {
-            sendFlood(reply);
+            sendFlood(reply, SERVER_RESPONSE_DELAY);
           }
           }
         }
         }
       }
       }

+ 7 - 3
src/helpers/BaseChatMesh.cpp

@@ -1,6 +1,10 @@
 #include <helpers/BaseChatMesh.h>
 #include <helpers/BaseChatMesh.h>
 #include <Utils.h>
 #include <Utils.h>
 
 
+#ifndef SERVER_RESPONSE_DELAY
+  #define SERVER_RESPONSE_DELAY   300
+#endif
+
 #ifndef TXT_ACK_DELAY
 #ifndef TXT_ACK_DELAY
   #define TXT_ACK_DELAY     200
   #define TXT_ACK_DELAY     200
 #endif
 #endif
@@ -191,14 +195,14 @@ void BaseChatMesh::onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender
         // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
         // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
         mesh::Packet* path = createPathReturn(from.id, secret, packet->path, packet->path_len,
         mesh::Packet* path = createPathReturn(from.id, secret, packet->path, packet->path_len,
                                               PAYLOAD_TYPE_RESPONSE, temp_buf, reply_len);
                                               PAYLOAD_TYPE_RESPONSE, temp_buf, reply_len);
-        if (path) sendFlood(path);
+        if (path) sendFlood(path, SERVER_RESPONSE_DELAY);
       } else {
       } else {
         mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, from.id, secret, temp_buf, reply_len);
         mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, from.id, secret, temp_buf, reply_len);
         if (reply) {
         if (reply) {
           if (from.out_path_len >= 0) {  // we have an out_path, so send DIRECT
           if (from.out_path_len >= 0) {  // we have an out_path, so send DIRECT
-            sendDirect(reply, from.out_path, from.out_path_len);
+            sendDirect(reply, from.out_path, from.out_path_len, SERVER_RESPONSE_DELAY);
           } else {
           } else {
-            sendFlood(reply);
+            sendFlood(reply, SERVER_RESPONSE_DELAY);
           }
           }
         }
         }
       }
       }