Skip to content

Commit

Permalink
Fix issue #157 and #158
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Oct 5, 2024
1 parent 4b171a9 commit cab41d4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/mobizt/FirebaseClient/.github%2Fworkflows%2Fcompile_library.yml?logo=github&label=compile) [![Github Stars](https://img.shields.io/github/stars/mobizt/FirebaseClient?logo=github)](https://github.com/mobizt/FirebaseClient/stargazers) ![Github Issues](https://img.shields.io/github/issues/mobizt/FirebaseClient?logo=github)

![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.3.12-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)
![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.4.0-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)

[![GitHub Sponsors](https://img.shields.io/github/sponsors/mobizt?logo=github)](https://github.com/sponsors/mobizt)

Revision `2024-10-02T12:03:28Z`
Revision `2024-10-05T05:27:46Z`

## Table of Contents

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FirebaseClient",
"version": "1.3.12",
"version": "1.4.0",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "Async Firebase Client library for Arduino.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=FirebaseClient

version=1.3.12
version=1.4.0

author=Mobizt

Expand Down
21 changes: 12 additions & 9 deletions src/core/AsyncClient/AsyncClient.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Created July 30, 2024
* Created October 6, 2024
*
* For MCU build target (CORE_ARDUINO_XXXX), see Options.h.
*
Expand Down Expand Up @@ -86,7 +86,6 @@ struct async_data_item_t
bool auth_used = false;
bool complete = false;
bool async = false;
bool cancel = false;
bool sse = false;
bool path_not_existed = false;
bool download = false;
Expand Down Expand Up @@ -130,7 +129,6 @@ struct async_data_item_t
auth_used = false;
complete = false;
async = false;
cancel = false;
sse = false;
path_not_existed = false;
cb = NULL;
Expand Down Expand Up @@ -1916,7 +1914,7 @@ class AsyncClientClass : public ResultBase, RTDBResultBase

bool handleSendTimeout(async_data_item_t *sData)
{
if (sData->request.send_timer.remaining() == 0 || sData->cancel)
if (sData->request.send_timer.remaining() == 0)
{
// In case TCP write error.
setAsyncError(sData, sData->state, FIREBASE_ERROR_TCP_SEND, !sData->sse, false);
Expand All @@ -1930,7 +1928,7 @@ class AsyncClientClass : public ResultBase, RTDBResultBase

bool handleReadTimeout(async_data_item_t *sData)
{
if (!sData->sse && (sData->response.read_timer.remaining() == 0 || sData->cancel))
if (!sData->sse && sData->response.read_timer.remaining() == 0)
{
// In case TCP read error.
setAsyncError(sData, sData->state, FIREBASE_ERROR_TCP_RECEIVE_TIMEOUT, !sData->sse, false);
Expand Down Expand Up @@ -1976,16 +1974,21 @@ class AsyncClientClass : public ResultBase, RTDBResultBase
{
sys_idle();
async_data_item_t *sData = getData(i);
if (sData && sData->async && !sData->auth_used && !sData->cancel)
if (sData && sData->async && !sData->auth_used && !sData->to_remove)
{
// Reset the app data to reset clear the available status when the task was canceled.
sData->aResult.reset(sData->aResult.app_data);
if (getResult(sData))
getResult(sData)->reset(getResult(sData)->app_data);

if (uid.length())
{
if (strcmp(sData->aResult.uid().c_str(), uid.c_str()) == 0)
sData->cancel = true;
sData->to_remove = true;
}
else
{
sData->cancel = true;
sData->to_remove = true;
if (!all)
break;
}
Expand Down Expand Up @@ -2062,7 +2065,7 @@ class AsyncClientClass : public ResultBase, RTDBResultBase
if (!options.auth_used)
{
sData->request.app_token = options.app_token;
if (options.app_token && !options.auth_param && (options.app_token->auth_type == auth_id_token || options.app_token->auth_type == auth_user_id_token || options.app_token->auth_type == auth_access_token || options.app_token->auth_type == auth_sa_access_token))
if (options.app_token && !options.auth_param && (options.app_token->auth_type > auth_unknown_token && options.app_token->auth_type < auth_refresh_token))
{
sData->request.addAuthHeaderFirst(options.app_token->auth_type);
sData->request.val[req_hndlr_ns::header] += FIREBASE_AUTH_PLACEHOLDER;
Expand Down
4 changes: 2 additions & 2 deletions src/core/AsyncClient/RequestHandler.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Created July 6, 2024
* Created October 6, 2024
*
* The MIT License (MIT)
* Copyright (c) 2024 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -237,7 +237,7 @@ struct async_request_handler_t
val[req_hndlr_ns::header] += FPSTR("Authorization: ");
if (type == auth_access_token || type == auth_sa_access_token)
val[req_hndlr_ns::header] += FPSTR("Bearer ");
else if (type == auth_user_id_token || type == auth_id_token || type == auth_custom_token)
else if (type == auth_user_id_token || type == auth_id_token || type == auth_custom_token || type == auth_sa_custom_token)
val[req_hndlr_ns::header] += FPSTR("Firebase ");
else
val[req_hndlr_ns::header] += FPSTR("key=");
Expand Down
2 changes: 1 addition & 1 deletion src/core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#undef FIREBASE_CLIENT_VERSION
#endif

#define FIREBASE_CLIENT_VERSION "1.3.12"
#define FIREBASE_CLIENT_VERSION "1.4.0"

static void sys_idle()
{
Expand Down

0 comments on commit cab41d4

Please sign in to comment.