|
25 | 25 | #include<WiFiClientSecure.h>
|
26 | 26 | #include<ESP8266HTTPClient.h>
|
27 | 27 |
|
| 28 | +//TODO(edcoyne) split these into multiple files. |
| 29 | + |
| 30 | +// Result from call to Firebase backend. ALWAYS check isError() before |
| 31 | +// expecting any data. |
28 | 32 | classFirebaseResult {
|
29 | 33 | public:
|
30 | 34 | FirebaseResult(int status);
|
31 | 35 | FirebaseResult(int status,const String& response);
|
32 | 36 | FirebaseResult(const FirebaseResult& result);
|
33 | 37 |
|
| 38 | +// True if there was an error completeing call. |
34 | 39 | boolisError()const;
|
35 |
| -boolisOk()const; |
36 | 40 | StringerrorMessage()const;
|
| 41 | + |
| 42 | +// True if http status code is 200(OK). |
| 43 | +boolisOk()const; |
| 44 | +// Message sent back from Firebase backend. |
37 | 45 | const String&response()const;
|
38 | 46 |
|
39 | 47 | inthttpStatus()const {
|
40 | 48 | return status_;
|
41 | 49 | }
|
42 | 50 |
|
43 |
| -protected: |
| 51 | +private: |
44 | 52 | int status_;
|
45 | 53 | String response_;
|
46 | 54 | };
|
47 | 55 |
|
| 56 | +// Low level connection to Firebase backend, you probably want the |
| 57 | +// Firebase class below. |
48 | 58 | classFirebaseConnection {
|
49 | 59 | public:
|
50 | 60 | FirebaseConnection(const String& host);
|
@@ -72,7 +82,7 @@ class FirebaseConnection {
|
72 | 82 | String auth_;
|
73 | 83 | };
|
74 | 84 |
|
75 |
| -//Firebase istheconnection to firebase. |
| 85 | +//Primary client totheFirebase backend. |
76 | 86 | classFirebase {
|
77 | 87 | public:
|
78 | 88 | Firebase(const String& host);
|
@@ -104,14 +114,19 @@ class FirebaseEventStream {
|
104 | 114 | FirebaseEventStream(const String& host);
|
105 | 115 | FirebaseEventStream&auth(const String& auth);
|
106 | 116 |
|
| 117 | +// Connect to backend and start receiving events. |
107 | 118 | FirebaseResultconnect(const String& path);
|
| 119 | +// Read next event in stream. |
108 | 120 | Eventread(String& event);
|
109 | 121 |
|
| 122 | +// True if connected to backend. |
110 | 123 | boolconnected();
|
| 124 | + |
| 125 | +// True if there is an event available. |
111 | 126 | boolavailable();
|
| 127 | + |
112 | 128 | private:
|
113 | 129 | FirebaseConnection connection_;
|
114 | 130 | };
|
115 | 131 |
|
116 |
| - |
117 | 132 | #endif// firebase_h
|