|
pianod2
multisource multiuser scriptable networked music player
|
A response collector/aggregator. More...
#include <response.h>


Public Member Functions | |
| void | setNoResponse () |
| bool | allSuccess () const |
| ResponseCollector contains successes but no failures. More... | |
| bool | allFailure () const |
| ResponseCollector contains failures but no successes. More... | |
| bool | anySuccess () const |
| ResponseCollector contains at least one success, regardless of failures. More... | |
| bool | anyFailure () const |
| ResponseCollector contains at least one failure, regardless of successes. More... | |
| bool | partial () const |
| ResponseCollector contains a mix of successes and failures. More... | |
| bool | noop () const |
| ResponseCollector contains neither successes nor failures. More... | |
| bool | dataResponse () const |
| ResponseCollector is transporting data for transmission. More... | |
| bool | isNoResponse () const |
| ResponseCollector should not send a reply to a command. More... | |
| void | close () |
| Causes the connection to be closed after the response is sent. More... | |
| void | transmit (PianodConnection &, const bool json) |
| Transmit a reply. More... | |
| ResponseCollector ()=default | |
| ResponseCollector (ResponseCollector &&from)=default | |
| ResponseCollector & | operator= (ResponseCollector &&from)=default |
| ResponseCollector (Response &&initial) | |
| Initialize a response collection, and add the initial response to the appropriate collection if applicable. More... | |
| ResponseCollector (const RESPONSE_CODE response) | |
| ResponseCollector (MusicThingie *item) | |
| Implicitly wrap a music item into a data response. More... | |
| ResponseCollector (const ThingieList &things) | |
| Implicitly wrap a list of music items into a data response. More... | |
| ResponseCollector (const SongList &songs) | |
| Implicitly wrap a list of songs into a data response. More... | |
| ResponseCollector (ResponseGroup &&group) | |
| Implicitly wrap a response group into a data response. More... | |
Public Attributes | |
| ResponseGroup | information |
| Session notices going back to user. More... | |
Protected Member Functions | |
| void | data (ResponseGroup &&group) |
| Add a record for transmission as response data. More... | |
| void | data (const ThingieList &item_list) |
| Add a list of music items for transmission as response data. More... | |
| void | data (const SongList &songs) |
| Add a list of songs for transmission as response data. More... | |
| void | data (const PlaylistList &playlists) |
| Add a list of playlists for transmission as response data. More... | |
Protected Attributes | |
| RESPONSE_CODE | reason { S_NOOP } |
| The final response that will be sent. More... | |
| ResponseGroup | successes |
| Success messages. More... | |
| ResponseGroup | diagnostics |
| Details of errors encountered. More... | |
| std::vector< ResponseGroup > | data_groups |
| Complete data records destined for the client. More... | |
| ResponseGroup | data_reply |
| Discrete data responses destined for the client. More... | |
| ResponseGroup | user_events |
| Broadcast to other same-user sessions. More... | |
| ResponseGroup | room_events |
| Broadcast to all same-room sessions. More... | |
| ResponseGroup | broadcast_events |
| Broadcast to all users, all rooms. More... | |
Private Member Functions | |
| Parsnip::Data | serialize (const User *user) const |
| Assemble a response collection into either a data response or a reply (i.e., successes/failures). More... | |
| void | transmitJSON (PianodConnection &) const |
| Format and transmit a response collection to JSON client. More... | |
| void | transmitLine (PianodConnection &) const |
| Transmit a data response OR command reply to a specific node, followed by any client-specific add-on information. More... | |
Private Attributes | |
| bool | close_after_response = false |
| If true, the connection is closed after response is sent. More... | |
Friends | |
| class PianodConnection & | operator<< (class PianodConnection &there, const ResponseCollector &response) |
A response collector/aggregator.
This class implements a "funnel" pattern. Whatever is coming back from user commands—success indications, error messages, status updates, and data—is passed back through this structure, then serialized into a message and sent. Note: This class is used to return data, but the child DataResponse class is used to construct data responses.
|
default |
|
default |
| ResponseCollector::ResponseCollector | ( | Response && | initial | ) |
Initialize a response collection, and add the initial response to the appropriate collection if applicable.

|
inline |
| ResponseCollector::ResponseCollector | ( | MusicThingie * | item | ) |
Implicitly wrap a music item into a data response.
| ResponseCollector::ResponseCollector | ( | const ThingieList & | things | ) |
Implicitly wrap a list of music items into a data response.

| ResponseCollector::ResponseCollector | ( | const SongList & | songs | ) |
Implicitly wrap a list of songs into a data response.

| ResponseCollector::ResponseCollector | ( | ResponseGroup && | group | ) |
Implicitly wrap a response group into a data response.
|
inline |
|
inline |
|
inline |
ResponseCollector contains at least one failure, regardless of successes.
|
inline |
ResponseCollector contains at least one success, regardless of failures.

|
inline |
Causes the connection to be closed after the response is sent.

|
protected |
Add a list of playlists for transmission as response data.
|
protected |
Add a list of songs for transmission as response data.
|
protected |
Add a list of music items for transmission as response data.
|
protected |
Add a record for transmission as response data.

|
inline |
ResponseCollector is transporting data for transmission.

|
inline |
|
inline |
ResponseCollector contains neither successes nor failures.

|
default |
|
inline |
ResponseCollector contains a mix of successes and failures.

|
private |
Assemble a response collection into either a data response or a reply (i.e., successes/failures).


|
inline |

| void ResponseCollector::transmit | ( | PianodConnection & | destination, |
| const bool | json | ||
| ) |
Transmit a reply.
Send requested data or reply to the requesting node using their desired protocol. Broadcast events as follows, using the appropriate protocol for each node:
| destination | The client to which to send the reponse. |
| json | If true, use JSON for data or reply; otherwise use line protocol. |


|
private |
Format and transmit a response collection to JSON client.
| destination | The client to which to send the reply. |


|
private |
Transmit a data response OR command reply to a specific node, followed by any client-specific add-on information.
| destination | The node to which to send the response or data. |


|
friend |
|
protected |
Broadcast to all users, all rooms.
|
private |
If true, the connection is closed after response is sent.
|
protected |
Complete data records destined for the client.
|
protected |
Discrete data responses destined for the client.
|
protected |
Details of errors encountered.
| ResponseGroup ResponseCollector::information |
Session notices going back to user.
|
protected |
The final response that will be sent.
|
protected |
Broadcast to all same-room sessions.
|
protected |
Success messages.
|
protected |
Broadcast to other same-user sessions.