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

Commit74ee904

Browse files
committed
Merge pull requestFirebaseExtended#53 from proppy/missing-set
firebase: restore set method
2 parents64a5de8 +65ec1bf commit74ee904

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

‎Firebase.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ FirebaseGet Firebase::get(const String& path) {
4646
returnFirebaseGet(host_, auth_, path, &http_);
4747
}
4848

49+
FirebaseSetFirebase::set(const String& path,const String& value) {
50+
returnFirebaseSet(host_, auth_, path, value, &http_);
51+
}
52+
4953
FirebasePushFirebase::push(const String& path,const String& value) {
5054
returnFirebasePush(host_, auth_, path, value, &http_);
5155
}
@@ -115,6 +119,17 @@ FirebaseGet::FirebaseGet(const String& host, const String& auth,
115119
}
116120
}
117121

122+
// FirebaseSet
123+
FirebaseSet::FirebaseSet(const String& host,const String& auth,
124+
const String& path,const String& value,
125+
HTTPClient* http)
126+
: FirebaseCall(host, auth,"PUT", path, value, http) {
127+
128+
if (!error()) {
129+
// TODO: parse json
130+
json_ =response();
131+
}
132+
}
118133
// FirebasePush
119134
FirebasePush::FirebasePush(const String& host,const String& auth,
120135
const String& path,const String& value,

‎Firebase.h

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,30 @@
2626
#include<ESP8266HTTPClient.h>
2727

2828
classFirebaseGet;
29+
classFirebaseSet;
2930
classFirebasePush;
3031
classFirebaseRemove;
3132
classFirebaseStream;
3233

33-
//Primary client to the Firebase backend.
34+
//Firebase REST API client.
3435
classFirebase {
3536
public:
3637
Firebase(const String& host);
3738
Firebase&auth(const String& auth);
3839

39-
// Fetchresultat"path".
40+
// Fetchjson encoded `value`at`path`.
4041
FirebaseGetget(const String& path);
4142

42-
//Add newvalue to listat"path", will return key for the new item.
43-
FirebasePushpush(const String& path,const String&value);
43+
//Set json encoded `value`at`path`.
44+
FirebaseSetset(const String& path,const String&json);
4445

45-
// Deletes value at "path" from firebase.
46+
// Add new json encoded `value` to list at `path`.
47+
FirebasePushpush(const String& path,const String& json);
48+
49+
// Delete value at `path`.
4650
FirebaseRemoveremove(const String& path);
4751

48-
// Starts a stream of events that affect object at "path".
49-
// TODO: fix FirebaseStream lifecycle
50-
// https://github.com/esp8266/Arduino/issues/500
52+
// Start a stream of events that affect value at `path`.
5153
FirebaseStreamstream(const String& path);
5254

5355
private:
@@ -102,6 +104,20 @@ class FirebaseGet : public FirebaseCall {
102104
String json_;
103105
};
104106

107+
classFirebaseSet:publicFirebaseCall {
108+
public:
109+
FirebaseSet() {}
110+
FirebaseSet(const String& host,const String& auth,
111+
const String& path,const String& value, HTTPClient* http =NULL);
112+
113+
const String&json()const {
114+
return json_;
115+
}
116+
117+
private:
118+
String json_;
119+
};
120+
105121
classFirebasePush :publicFirebaseCall {
106122
public:
107123
FirebasePush() {}
@@ -130,17 +146,17 @@ class FirebaseStream : public FirebaseCall {
130146
FirebaseStream(const String& host,const String& auth,
131147
const String& path, HTTPClient* http =NULL);
132148

133-
//True if there isan event available.
149+
//Return if there isany event available to read.
134150
boolavailable();
135151

136-
//event type.
152+
//Event type.
137153
enum Event {
138154
UNKNOWN,
139155
PUT,
140156
PATCH
141157
};
142158

143-
// Read next event in stream.
159+
// Read nextjson encoded `event` from stream.
144160
Eventread(String& event);
145161

146162
const FirebaseError&error()const {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp