Skip to content

Commit

Permalink
Fix authentication and external Client issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Sep 19, 2022
1 parent 27ac140 commit 32cdde9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
18 changes: 9 additions & 9 deletions src/rtdb/FB_RTDB.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Google's Firebase Realtime Database class, FB_RTDB.cpp version 2.0.3
* Google's Firebase Realtime Database class, FB_RTDB.cpp version 2.0.4
*
* This library supports Espressif ESP8266 and ESP32
*
* Created September 18, 2022
* Created September 19, 2022
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2022 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -764,12 +764,12 @@ void FB_RTDB::setStreamCallback(FirebaseData *fbdo, FirebaseData::StreamEventCal
fbdo->_dataAvailableCallback = dataAvailableCallback;
fbdo->_timeoutCallback = timeoutCallback;

fbdo->addPtrList(fb_esp_con_mode_rtdb_stream);
fbdo->addAddr(fb_esp_con_mode_rtdb_stream);

#if defined(ESP32)
MB_String taskName = fb_esp_pgm_str_72;
taskName += fb_esp_pgm_str_113;
taskName += fbdo->so_addr;
taskName += fbdo->addr;

if (streamTaskStackSize > STREAM_TASK_STACK_SIZE)
cfg->internal.stream_task_stack_size = streamTaskStackSize;
Expand Down Expand Up @@ -809,12 +809,12 @@ void FB_RTDB::setMultiPathStreamCallback(FirebaseData *fbdo, FirebaseData::Multi
fbdo->_multiPathDataCallback = multiPathDataCallback;
fbdo->_timeoutCallback = timeoutCallback;

fbdo->addPtrList(fb_esp_con_mode_rtdb_stream);
fbdo->addAddr(fb_esp_con_mode_rtdb_stream);

#if defined(ESP32)
MB_String taskName = fb_esp_pgm_str_72;
taskName += fb_esp_pgm_str_113;
taskName += fbdo->so_addr;
taskName += fbdo->addr;

if (streamTaskStackSize > STREAM_TASK_STACK_SIZE)
cfg->internal.stream_task_stack_size = streamTaskStackSize;
Expand Down Expand Up @@ -844,7 +844,7 @@ void FB_RTDB::removeMultiPathStreamCallback(FirebaseData *fbdo)

fbdo->_multiPathDataCallback = NULL;
fbdo->_timeoutCallback = NULL;
fbdo->removePtrList();
fbdo->removeAddr();

#if defined(ESP32)
if (cfg->internal.fbdo_addr_list.size() == 0)
Expand Down Expand Up @@ -1097,7 +1097,7 @@ void FB_RTDB::beginAutoRunErrorQueue(FirebaseData *fbdo, FirebaseData::QueueInfo

MB_String taskName = fb_esp_pgm_str_72;
taskName += fb_esp_pgm_str_114;
taskName += fbdo->so_addr;
taskName += fbdo->addr;

if (queueTaskStackSize > QUEUE_TASK_STACK_SIZE)
cfg->internal.queue_task_stack_size = queueTaskStackSize;
Expand Down Expand Up @@ -3947,7 +3947,7 @@ void FB_RTDB::removeStreamCallback(FirebaseData *fbdo)
fbdo->session.response.code = FIREBASE_ERROR_UNINITIALIZED;
return;
}
fbdo->removePtrList();
fbdo->removeAddr();

fbdo->_dataAvailableCallback = NULL;
fbdo->_timeoutCallback = NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/rtdb/FB_RTDB.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Google's Firebase Realtime Database class, FB_RTDB.h version 2.0.3
* Google's Firebase Realtime Database class, FB_RTDB.h version 2.0.4
*
* This library supports Espressif ESP8266 and ESP32
*
* Created September 18, 2022
* Created September 19, 2022
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2022 K. Suwatchai (Mobizt)
Expand Down
28 changes: 14 additions & 14 deletions src/session/FB_Session.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Google's Firebase Data class, FB_Session.cpp version 1.2.24
* Google's Firebase Data class, FB_Session.cpp version 1.2.25
*
* This library supports Espressif ESP8266 and ESP32
*
* Created September 18, 2022
* Created September 19, 2022
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2022 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -92,35 +92,35 @@ void FirebaseData::setNetworkStatus(bool status)
#endif
}

void FirebaseData::addPtrList(fb_esp_con_mode mode)
void FirebaseData::addAddr(fb_esp_con_mode mode)
{
if (!Signer.getCfg())
return;

removePtrList();
removeAddr();

if (so_addr == 0)
if (addr == 0)
{
so_addr = toAddr(*this);
Signer.getCfg()->internal.fbdo_addr_list.push_back(so_addr);
addr = toAddr(*this);
Signer.getCfg()->internal.fbdo_addr_list.push_back(addr);
session.con_mode = mode;
}
}

void FirebaseData::removePtrList()
void FirebaseData::removeAddr()
{
if (!Signer.getCfg())
return;

if (so_addr > 0)
if (addr > 0)
{
for (size_t i = 0; i < Signer.getCfg()->internal.fbdo_addr_list.size(); i++)
{
if (so_addr > 0 && Signer.getCfg()->internal.fbdo_addr_list[i] == so_addr)
if (addr > 0 && Signer.getCfg()->internal.fbdo_addr_list[i] == addr)
{
session.con_mode = fb_esp_con_mode_undefined;
Signer.getCfg()->internal.fbdo_addr_list.erase(Signer.getCfg()->internal.fbdo_addr_list.begin() + i);
so_addr = 0;
addr = 0;
break;
}
}
Expand Down Expand Up @@ -160,9 +160,6 @@ bool FirebaseData::init()
if (!Signer.getCfg())
return false;

if (so_addr == 0)
addPtrList(fb_esp_con_mode_undefined);

this->ut = Signer.getUtils();

this->mbfs = Signer.getMBFS();
Expand Down Expand Up @@ -935,6 +932,9 @@ void FirebaseData::setTimeout()

void FirebaseData::setSecure()
{
if (addr == 0)
addAddr(fb_esp_con_mode_undefined);

setTimeout();

tcpClient.setMBFS(mbfs);
Expand Down
10 changes: 5 additions & 5 deletions src/session/FB_Session.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Google's Firebase Data class, FB_Session.h version 1.2.24
* Google's Firebase Data class, FB_Session.h version 1.2.25
*
* This library supports Espressif ESP8266 and ESP32
*
* Created September 18, 2022
* Created September 19, 2022
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2022 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -892,7 +892,7 @@ class FirebaseData
bool intCfg = false;
unsigned long last_reconnect_millis = 0;
uint16_t reconnect_tmo = 10 * 1000;
uint32_t so_addr = 0;
uint32_t addr = 0;
uint32_t queue_addr = 0;

#ifdef ENABLE_RTDB
Expand Down Expand Up @@ -950,8 +950,8 @@ class FirebaseData
#endif

bool init();
void addPtrList(fb_esp_con_mode mode);
void removePtrList();
void addAddr(fb_esp_con_mode mode);
void removeAddr();
void addQueueAddr();
void removeQueueAddr();
void setRaw(bool trim);
Expand Down

0 comments on commit 32cdde9

Please sign in to comment.