Own fork of MbedSmartRest
Dependents: MbedSmartRestMain MbedSmartRestMain
Fork of MbedSmartRest by
Diff: AbstractClient.h
- Revision:
- 11:e1bee9a77652
- Parent:
- 6:cd7ba1ddb664
- Child:
- 20:505d29d5bdfc
--- a/AbstractClient.h Thu Oct 23 14:41:58 2014 +0200 +++ b/AbstractClient.h Sat Nov 15 11:21:01 2014 +0100 @@ -51,9 +51,9 @@ * * All methods have to be called in the following order: * - setAuthorization() - * - beginRequest() + * - beginRequest() or beginStream() * - sendIdentifier() (optional) - * - sendData() (optional) + * - sendData() (optional if in request mode) * - endRequest() * - awaitResponse() * - receiveData() (optional) @@ -66,68 +66,76 @@ */ class AbstractClient { -public: - virtual ~AbstractClient() { }; + public: + virtual ~AbstractClient() { }; - /** - * Sets authorization username and password. This method can only be - * called when no request is processing. Values set using this method - * must be kept in memory until either new values are set or the object - * is being destroyed. - * @param username the username used for further request authorization - * @param password the password used for further request authorization - */ - virtual uint8_t setAuthorization(const char*, const char*) = 0; + /** + * Sets authorization username and password. This method can only be + * called when no request is processing. Values set using this method + * must be kept in memory until either new values are set or the object + * is being destroyed. + * @param username the username used for further request authorization + * @param password the password used for further request authorization + */ + virtual uint8_t setAuthorization(const char*, const char*) = 0; - /** - * Begins a new request. This method has to be the first call for - * any request. A connection to the server will be established - * and the start of a HTTP post request will be sent over the - * connection including Host and Authorization headers. - */ - virtual uint8_t beginRequest() = 0; + /** + * Begins a new request. This method has to be the first call for + * any request. A connection to the server will be established + * and the start of a HTTP post request will be sent over the + * connection including Host and Authorization headers. + */ + virtual uint8_t beginRequest() = 0; - /** - * Sends the X-Id device identifier header. - * @param identifier the identifier to be sent. The value has to remain - * valid for the entire request. If null or empty, no - * identifier is sent. - */ - virtual uint8_t sendIdentifier(const char*) = 0; + /** + * Begins a new stream. This method has to be the first call for + * any request. A connection to the server will be established + * and the start of a HTTP post request will be sent over the + * connection including Host and Authorization headers. + */ + virtual uint8_t beginStream(const char*) = 0; - /** - * Sends POST data over the connection. Before the data is sent, - * a Content-Length header is also sent over the connection. if the - * estimated length does not match the actual conten length, - * unexpected behavior will occur. - * @param generator the data generator for the data to be sent - */ - virtual uint8_t sendData(const DataGenerator&) = 0; + /** + * Sends the X-Id device identifier header. + * @param identifier the identifier to be sent. The value has to remain + * valid for the entire request. If null or empty, no + * identifier is sent. + */ + virtual uint8_t sendIdentifier(const char*) = 0; - /** - * Finishes the request. In case no data has been sent over the - * connection, this method will send twice carriage-return new-line. - */ - virtual uint8_t endRequest() = 0; + /** + * Sends POST data over the connection. Before the data is sent, + * a Content-Length header is also sent over the connection. if the + * estimated length does not match the actual conten length, + * unexpected behavior will occur. + * @param generator the data generator for the data to be sent + */ + virtual uint8_t sendData(const DataGenerator&) = 0; - /** - * Blocks until the start of a response has been received. - */ - virtual uint8_t awaitResponse() = 0; + /** + * Finishes the request. In case no data has been sent over the + * connection, this method will send twice carriage-return new-line. + */ + virtual uint8_t endRequest() = 0; + + /** + * Blocks until the start of a response has been received. + */ + virtual uint8_t awaitResponse() = 0; - /** - * Returns a data source for reading data. - * When no data can be read for whatever reason, - * a data source with an error state may be returned. - * @return the data source to read from - */ - virtual AbstractDataSource& receiveData() = 0; + /** + * Returns a data source for reading data. + * When no data can be read for whatever reason, + * a data source with an error state may be returned. + * @return the data source to read from + */ + virtual AbstractDataSource& receiveData() = 0; - /** - * Resets the connection. This method can be called at any time - * and resets the state of this instance. - */ - virtual void stop() = 0; + /** + * Resets the connection. This method can be called at any time + * and resets the state of this instance. + */ + virtual void stop() = 0; }; #endif