Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit96eab42

Browse files
authored
Merge pull requestFirebaseExtended#296 from kotl/master
Improve stability of the repo
2 parentsf022066 +ed75682 commit96eab42

File tree

92 files changed

+156
-5222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+156
-5222
lines changed

‎.travis.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,27 @@ addons:
88
packages:
99
-g++-4.8
1010
env:
11-
-ARDUINO_VERSION=1.6.9 ARDUINO_ESP8266_VERSION=2.3.0 LIB_NEOPIXEL_VERSION=v1.0.5 LIB_GFX_VERSION=v1.1.5 LIB_SSD1306_VERSION=1.1.0 ARDUINO_ROOT=${HOME}/arduino-${ARDUINO_VERSION} ARDUINO_ESP8266_ROOT=${ARDUINO_ROOT}/hardware/esp8266com/esp8266 ARDUINO_HOME=${HOME}/Arduino
12-
-ARDUINO_VERSION=nightly ARDUINO_ESP8266_VERSION=master LIB_NEOPIXEL_VERSION=master LIB_GFX_VERSION=master LIB_SSD1306_VERSION=master ARDUINO_ROOT=${HOME}/arduino-${ARDUINO_VERSION} ARDUINO_ESP8266_ROOT=${ARDUINO_ROOT}/hardware/esp8266com/esp8266 ARDUINO_HOME=${HOME}/Arduino
11+
-ARDUINO_VERSION=1.6.9 ARDUINO_ESP8266_VERSION=2.3.0 LIB_NEOPIXEL_VERSION=v1.0.5 LIB_GFX_VERSION=v1.1.5 LIB_SSD1306_VERSION=1.1.0LIB_JSON_VERSION=v5.11.2ARDUINO_ROOT=${HOME}/arduino-${ARDUINO_VERSION} ARDUINO_ESP8266_ROOT=${ARDUINO_ROOT}/hardware/esp8266com/esp8266 ARDUINO_HOME=${HOME}/Arduino
12+
-ARDUINO_VERSION=nightly ARDUINO_ESP8266_VERSION=master LIB_NEOPIXEL_VERSION=master LIB_GFX_VERSION=master LIB_SSD1306_VERSION=masterLIB_JSON_VERSION=masterARDUINO_ROOT=${HOME}/arduino-${ARDUINO_VERSION} ARDUINO_ESP8266_ROOT=${ARDUINO_ROOT}/hardware/esp8266com/esp8266 ARDUINO_HOME=${HOME}/Arduino
1313
install:
1414
-if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
1515
-( cd ${HOME} && wget https://downloads.arduino.cc/arduino-${ARDUINO_VERSION}-linux64.tar.xz && tar xf arduino-${ARDUINO_VERSION}-linux64.tar.xz )
1616
-( LIB=SoftwareSerial VERSION=097712eb07f5b3a70ef419b6e7a7ed2ada5aab85 && cd ${HOME} && wget https://github.com/plerup/espsoftwareserial/archive/${VERSION}.zip -q -O ${LIB}.zip && unzip -q ${LIB}.zip && rm ${LIB}.zip && mv espsoftwareserial-* ${LIB} )
1717
-( LIB=Adafruit_NeoPixel VERSION=${LIB_NEOPIXEL_VERSION} && cd ${HOME} && wget https://github.com/adafruit/${LIB}/archive/${VERSION}.zip -q -O ${LIB}.zip && unzip -q ${LIB}.zip && rm ${LIB}.zip && mv ${LIB}-* ${LIB} )
1818
-( LIB=Adafruit-GFX-Library VERSION=${LIB_GFX_VERSION} && cd ${HOME} && wget https://github.com/adafruit/${LIB}/archive/${VERSION}.zip -q -O ${LIB}.zip && unzip -q ${LIB}.zip && rm ${LIB}.zip && mv ${LIB}-* ${LIB} )
1919
-( LIB=Adafruit_SSD1306 VERSION=${LIB_SSD1306_VERSION} && cd ${HOME} && wget https://github.com/adafruit/${LIB}/archive/${VERSION}.zip -q -O ${LIB}.zip && unzip -q ${LIB}.zip && rm ${LIB}.zip && mv ${LIB}-* ${LIB} )
20+
-( LIB=ArduinoJson VERSION=${LIB_JSON_VERSION} && cd ${HOME} && wget https://github.com/bblanchon/${LIB}/archive/${VERSION}.zip -q -O ${LIB}.zip && unzip -q ${LIB}.zip && rm ${LIB}.zip && mv ${LIB}-* ${LIB} )
2021
-git clone --branch ${ARDUINO_ESP8266_VERSION} https://github.com/esp8266/Arduino.git ${ARDUINO_ESP8266_ROOT}
2122
-git submodule init && git submodule update
2223
-( cd ${ARDUINO_ESP8266_ROOT}/tools && python get.py )
2324
before_script:
2425
-mkdir -p ${ARDUINO_HOME}/libraries
25-
-( cd ${ARDUINO_HOME}/libraries && ln -s ${TRAVIS_BUILD_DIR} firebase-arduino && ln -s ${TRAVIS_BUILD_DIR}/src/third-party/arduino-json-5.6.7 ArduinoJson&& ln -s ${HOME}/SoftwareSerial ./ && ln -s ${HOME}/Adafruit_NeoPixel ./ && ln -s ${HOME}/Adafruit-GFX-Library ./ && ln -s ${HOME}/Adafruit_SSD1306 ./)
26+
-( cd ${ARDUINO_HOME}/libraries && ln -s ${TRAVIS_BUILD_DIR} firebase-arduino && ln -s ${HOME}/SoftwareSerial ./&& ln -s ${HOME}/Adafruit_NeoPixel ./ && ln -s ${HOME}/Adafruit-GFX-Library ./ && ln -s ${HOME}/Adafruit_SSD1306 ./ && ln -s ${HOME}/ArduinoJson ./)
2627
script:
27-
-${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseDemo_ESP8266/FirebaseDemo_ESP8266.ino
28-
-${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseNeoPixel_ESP8266/FirebaseNeoPixel_ESP8266.ino
29-
-${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino
30-
-${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseRoom_ESP8266/FirebaseRoom_ESP8266.ino
28+
-${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M-prefs build.f_cpu=80000000examples/FirebaseDemo_ESP8266/FirebaseDemo_ESP8266.ino
29+
-${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M-prefs build.f_cpu=80000000examples/FirebaseNeoPixel_ESP8266/FirebaseNeoPixel_ESP8266.ino
30+
-${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M-prefs build.f_cpu=80000000examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino
31+
-${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M-prefs build.f_cpu=80000000examples/FirebaseRoom_ESP8266/FirebaseRoom_ESP8266.ino
3132
-( cd contrib/test && make check )
3233
-( cd contrib/test/modem/ && make test )
3334
-contrib/test/travis/check_all_examples_use_standard_init.sh

‎README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ The Arduino library is [under heavy development](https://github.com/googlesample
1919

2020
-[FirebaseArduino API Reference](http://firebase-arduino.readthedocs.io/)
2121

22+
##Dependencies
23+
- FirebaseArduino now depends on[ArduinoJson library](https://github.com/bblanchon/ArduinoJson) instead of containing it's own version of it. Please either use Library Manager or download specific version of the library from github.
24+
2225
##Disclaimer
2326

2427
*This is not an official Google product*.

‎README.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ FirebaseArduino is a library to simplify connecting to the Firebase database fro
22
arduino clients.
33

44
It is a full abstraction of Firebase's REST API exposed through C++ calls in a wiring
5-
friendly way. All Json parsing is handled by the library and you may deal in pure C/Arduino
6-
types.
5+
friendly way.
6+
7+
ArduinoJson is no longer part of this library and you will have to install latest version
8+
in Arduino environment yourself. (through Board manager or download+unpack from master:
9+
https://github.com/bblanchon/ArduinoJson)
710

811
----------------------------------

‎contrib/src/modem/db/stream-command.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ bool StreamCommand::execute(const String& command,
3232
out->print(FirebaseStream::EventToName(event).c_str());
3333
out->print("");
3434
constauto& object = buffer.parseObject(json.c_str());
35-
String data = object["data"];
35+
String data = object["data"].asString();
3636
out->println(object["path"].asString());
3737
out->println(data.length());
3838
out->println(data);

‎contrib/src/thing/Config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include"Arduino.h"
22
#include"thing/Config.h"
3-
#include"third-party/arduino-json-5.6.7/include/ArduinoJson.h"
3+
#include<ArduinoJson.h>
44

55
namespacething {
66

‎contrib/src/thing/Config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include"Arduino.h"
55
#include<string>
66
#include<functional>
7-
#include"third-party/arduino-json-5.6.7/include/ArduinoJson.h"
7+
#include<ArduinoJson.h>
88

99
namespacething {
1010

‎contrib/src/thing/Portal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include"thing/Portal.h"
2-
#include"third-party/arduino-json-5.6.7/include/ArduinoJson.h"
2+
#include<ArduinoJson.h>
33

44
namespacething {
55

‎contrib/test/FirebaseArduino_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include"FirebaseObject.h"
1818
#include"gtest/gtest.h"
1919

20+
2021
TEST(FirebaseObjectTest, GetBool) {
2122
FirebaseObjectobj("true");
2223
EXPECT_EQ(true, obj.getBool());

‎contrib/test/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
FIREBASE_DIR=../..
1818
GTEST_DIR=googletest/googletest
19-
ARDUINOJSON_DIR=../../src/third-party/arduino-json-5.6.7
19+
ARDUINOJSON_DIR=${ARDUINO_HOME}/libraries/ArduinoJson
2020

2121
FIREBASE_SRCS=${FIREBASE_DIR}/src/FirebaseObject.cpp
2222
GTEST_SRCS=${GTEST_DIR}/src/gtest-all.cpp
@@ -27,7 +27,7 @@ SRCS=FirebaseArduino_test.cpp\
2727

2828
OBJS=${SRCS:.cpp=.o}
2929

30-
CXXFLAGS=-I. -I${FIREBASE_DIR}/src -Igoogletest/googletest/include -Igoogletest/googletest -std=c++11 -g
30+
CXXFLAGS=-I. -I${FIREBASE_DIR}/src -I${ARDUINOJSON_DIR}/src -Igoogletest/googletest/include -Igoogletest/googletest -std=c++11 -g
3131
LDFLAGS=-lpthread
3232

3333
all: check

‎contrib/test/modem/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ FIREBASE_ROOT = ../../..
3434
PROJECT_ROOT = ../..
3535
SRC_ROOT =$(PROJECT_ROOT)/src
3636
FIREBASE_SRC_ROOT =$(FIREBASE_ROOT)/src
37+
ARDUINOJSON_DIR=$(ARDUINO_HOME)/libraries/ArduinoJson
3738

3839
# Flags passed to the preprocessor.
3940
# Set Google Test and Google Mock's header directories as system
@@ -45,6 +46,7 @@ CPPFLAGS += -isystem $(GTEST_DIR)/include -isystem $(GMOCK_DIR)/include \
4546
-I$(PROJECT_ROOT)/test/dummies\
4647
-I$(PROJECT_ROOT)/src\
4748
-I$(FIREBASE_ROOT)/src\
49+
-I$(ARDUINOJSON_DIR)/src\
4850
-I$(PROJECT_ROOT)
4951

5052
# Flags passed to the C++ compiler.

‎contrib/test/modem/WString.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include<string>
2+
3+
typedef std::string String;

‎src/Firebase.cpp

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include"Firebase.h"
1717

1818
using std::unique_ptr;
19+
using std::shared_ptr;
1920

2021
namespace {
2122
std::stringmakeFirebaseURL(const std::string& path,const std::string& auth) {
@@ -42,55 +43,56 @@ const std::string& Firebase::auth() const {
4243
}
4344

4445
FirebaseGetFirebase::get(const std::string& path) {
45-
returnFirebaseGet(host_, auth_, path, http_.get());
46+
returnFirebaseGet(host_, auth_, path, http_);
4647
}
4748

48-
unique_ptr<FirebaseGet>Firebase::getPtr(const std::string& path) {
49-
return unique_ptr<FirebaseGet>(newFirebaseGet(host_, auth_, path, http_.get()));
49+
unique_ptr<FirebaseGet>Firebase::getPtr(const std::string& path) {
50+
return unique_ptr<FirebaseGet>(newFirebaseGet(host_, auth_, path, http_));
5051
}
5152

5253
FirebaseSetFirebase::set(const std::string& path,const std::string& value) {
53-
returnFirebaseSet(host_, auth_, path, value, http_.get());
54+
returnFirebaseSet(host_, auth_, path, value, http_);
5455
}
5556

56-
unique_ptr<FirebaseSet>Firebase::setPtr(const std::string& path,
57-
const std::string& value) {
58-
return unique_ptr<FirebaseSet>(
59-
newFirebaseSet(host_, auth_, path, value, http_.get()));
57+
unique_ptr<FirebaseSet>Firebase::setPtr(const std::string& path,
58+
const std::string& value) {
59+
return unique_ptr<FirebaseSet>(
60+
newFirebaseSet(host_, auth_, path, value, http_));
6061
}
6162

6263
FirebasePushFirebase::push(const std::string& path,const std::string& value) {
63-
returnFirebasePush(host_, auth_, path, value, http_.get());
64+
returnFirebasePush(host_, auth_, path, value, http_);
6465
}
65-
unique_ptr<FirebasePush>Firebase::pushPtr(const std::string& path,const std::string& value) {
66-
return unique_ptr<FirebasePush>(
67-
newFirebasePush(host_, auth_, path, value, http_.get()));
66+
67+
unique_ptr<FirebasePush>Firebase::pushPtr(const std::string& path,const std::string& value) {
68+
return unique_ptr<FirebasePush>(
69+
newFirebasePush(host_, auth_, path, value, http_));
6870
}
6971

7072
FirebaseRemoveFirebase::remove(const std::string& path) {
71-
returnFirebaseRemove(host_, auth_, path, http_.get());
73+
returnFirebaseRemove(host_, auth_, path, http_);
7274
}
7375

74-
unique_ptr<FirebaseRemove>Firebase::removePtr(const std::string& path) {
75-
return unique_ptr<FirebaseRemove>(
76-
newFirebaseRemove(host_, auth_, path, http_.get()));
76+
unique_ptr<FirebaseRemove>Firebase::removePtr(const std::string& path) {
77+
return unique_ptr<FirebaseRemove>(
78+
newFirebaseRemove(host_, auth_, path, http_));
7779
}
7880

7981
FirebaseStreamFirebase::stream(const std::string& path) {
8082
// TODO: create new client dedicated to stream.
81-
returnFirebaseStream(host_, auth_, path, http_.get());
83+
returnFirebaseStream(host_, auth_, path, http_);
8284
}
8385

84-
unique_ptr<FirebaseStream>Firebase::streamPtr(const std::string& path) {
85-
// TODO: create new client dedicated to stream.
86-
return unique_ptr<FirebaseStream>(
87-
newFirebaseStream(host_, auth_, path, http_.get()));
86+
unique_ptr<FirebaseStream>Firebase::streamPtr(const std::string& path) {
87+
// TODO: create new client dedicated to stream.
88+
return unique_ptr<FirebaseStream>(
89+
newFirebaseStream(host_, auth_, path, http_));
8890
}
8991

9092
// FirebaseCall
9193
FirebaseCall::FirebaseCall(const std::string& host,const std::string& auth,
9294
constchar* method,const std::string& path,
93-
const std::string& data, FirebaseHttpClient* http) : http_(http) {
95+
const std::string& data,const std::shared_ptr<FirebaseHttpClient> http) : http_(http) {
9496
std::string path_with_auth =makeFirebaseURL(path, auth);
9597
if ((method =="STREAM") && (path == http->getStreamingPath())){
9698
// already streaming requested path.
@@ -153,22 +155,24 @@ FirebaseCall::~FirebaseCall() {
153155

154156
const JsonObject&FirebaseCall::json() {
155157
//TODO(edcoyne): This is not efficient, we should do something smarter with
156-
//the buffers.
157-
buffer_ =DynamicJsonBuffer();
158-
return buffer_.parseObject(response().c_str());
158+
//the buffers. kotl: Is this still valid?
159+
if (buffer_.get() ==NULL) {
160+
buffer_.reset(new StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>());
161+
}
162+
return buffer_.get()->parseObject(response().c_str());
159163
}
160164

161165
// FirebaseGet
162166
FirebaseGet::FirebaseGet(const std::string& host,const std::string& auth,
163167
const std::string& path,
164-
FirebaseHttpClient* http)
168+
const std::shared_ptr<FirebaseHttpClient> http)
165169
: FirebaseCall(host, auth,"GET", path,"", http) {
166170
}
167171

168172
// FirebaseSet
169173
FirebaseSet::FirebaseSet(const std::string& host,const std::string& auth,
170174
const std::string& path,const std::string& value,
171-
FirebaseHttpClient* http)
175+
const std::shared_ptr<FirebaseHttpClient> http)
172176
: FirebaseCall(host, auth,"PUT", path, value, http) {
173177
if (!error()) {
174178
// TODO: parse json
@@ -179,7 +183,7 @@ FirebaseSet::FirebaseSet(const std::string& host, const std::string& auth,
179183
// FirebasePush
180184
FirebasePush::FirebasePush(const std::string& host,const std::string& auth,
181185
const std::string& path,const std::string& value,
182-
FirebaseHttpClient* http)
186+
const std::shared_ptr<FirebaseHttpClient> http)
183187
: FirebaseCall(host, auth,"POST", path, value, http) {
184188
if (!error()) {
185189
name_ =json()["name"].as<constchar*>();
@@ -189,26 +193,27 @@ FirebasePush::FirebasePush(const std::string& host, const std::string& auth,
189193
// FirebaseRemove
190194
FirebaseRemove::FirebaseRemove(const std::string& host,const std::string& auth,
191195
const std::string& path,
192-
FirebaseHttpClient* http)
196+
const std::shared_ptr<FirebaseHttpClient> http)
193197
: FirebaseCall(host, auth,"DELETE", path,"", http) {
194198
}
195199

196200
// FirebaseStream
197201
FirebaseStream::FirebaseStream(const std::string& host,const std::string& auth,
198202
const std::string& path,
199-
FirebaseHttpClient* http)
203+
const std::shared_ptr<FirebaseHttpClient> http)
200204
: FirebaseCall(host, auth,"STREAM", path,"", http) {
201205
}
202206

203207
boolFirebaseStream::available() {
204-
if (http_->getStreamPtr() ==nullptr) {
205-
returnfalse;
206-
}
207-
return http_->getStreamPtr()->available();
208+
auto client = http_->getStreamPtr();
209+
return (client ==nullptr) ?false : client->available();
208210
}
209211

210212
FirebaseStream::EventFirebaseStream::read(std::string& event) {
211213
auto client = http_->getStreamPtr();
214+
if (client ==nullptr) {
215+
returnEvent();
216+
}
212217
Event type;
213218
std::string typeStr = client->readStringUntil('\n').substring(7).c_str();
214219
if (typeStr =="put") {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp