Skip to content

Commit

Permalink
Update examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Jun 15, 2023
1 parent 60d1e13 commit 6478dad
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/DataChangesListener/Callback/Callback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ void setup()

// You can use TCP KeepAlive For more reliable stream operation and tracking the server connection status, please read this for detail.
// https://github.com/mobizt/Firebase-ESP8266#enable-tcp-keepalive-for-reliable-http-streaming
// You can use keepAlive in ESP8266 core version newer than v3.1.2.
// Or you can use git version (v3.1.2) https://github.com/esp8266/Arduino
// stream.keepAlive(5, 5, 1);

if (!Firebase.beginStream(stream, "/test/stream/data"))
Expand Down Expand Up @@ -215,4 +217,10 @@ void loop()
dataChanged = false;
// When stream data is available, do anything here...
}

// After calling stream.keepAlive, now we can track the server connecting status
if (!stream.httpConnected())
{
// Server was disconnected!
}
}
8 changes: 8 additions & 0 deletions examples/DataChangesListener/MultiPath/MultiPath.ino
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ void setup()

// You can use TCP KeepAlive For more reliable stream operation and tracking the server connection status, please read this for detail.
// https://github.com/mobizt/Firebase-ESP8266#enable-tcp-keepalive-for-reliable-http-streaming
// You can use keepAlive in ESP8266 core version newer than v3.1.2.
// Or you can use git version (v3.1.2) https://github.com/esp8266/Arduino
// stream.keepAlive(5, 5, 1);

// The data under the node being stream (parent path) should keep small
Expand Down Expand Up @@ -241,4 +243,10 @@ void loop()
dataChanged = false;
// When stream data is available, do anything here...
}

// After calling stream.keepAlive, now we can track the server connecting status
if (!stream.httpConnected())
{
// Server was disconnected!
}
}
8 changes: 8 additions & 0 deletions examples/DataChangesListener/NoCallback/NoCallback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ void setup()

// You can use TCP KeepAlive For more reliable stream operation and tracking the server connection status, please read this for detail.
// https://github.com/mobizt/Firebase-ESP8266#enable-tcp-keepalive-for-reliable-http-streaming
// You can use keepAlive in ESP8266 core version newer than v3.1.2.
// Or you can use git version (v3.1.2) https://github.com/esp8266/Arduino
// stream.keepAlive(5, 5, 1);

if (!Firebase.beginStream(stream, "/test/stream/data"))
Expand Down Expand Up @@ -203,4 +205,10 @@ void loop()
Serial.printf("Free Heap, %d\n", (int)ESP.getFreeHeap());
Serial.println();
}

// After calling stream.keepAlive, now we can track the server connecting status
if (!stream.httpConnected())
{
// Server was disconnected!
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ void setup()

// You can use TCP KeepAlive For more reliable stream operation and tracking the server connection status, please read this for detail.
// https://github.com/mobizt/Firebase-ESP8266#enable-tcp-keepalive-for-reliable-http-streaming
// You can use keepAlive in ESP8266 core version newer than v3.1.2.
// Or you can use git version (v3.1.2) https://github.com/esp8266/Arduino
// fbdo.keepAlive(5, 5, 1);

// The data under the node being stream (parent path) should keep small
Expand Down Expand Up @@ -169,4 +171,10 @@ void loop()
fbdo.stringData().c_str());
}
}

// After calling stream.keepAlive, now we can track the server connecting status
if (!fbdo.httpConnected())
{
// Server was disconnected!
}
}

0 comments on commit 6478dad

Please sign in to comment.