pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Private Member Functions | Friends | List of all members
ResponseGroup Class Reference

Container for multiple Responses. More...

#include <response.h>

Inheritance diagram for ResponseGroup:
Inheritance graph
[legend]
Collaboration diagram for ResponseGroup:
Collaboration graph
[legend]

Public Member Functions

 ResponseGroup ()=default
 
 ResponseGroup (ResponseGroup &&)=default
 
ResponseGroupoperator= (ResponseGroup &&)=default
 
 ResponseGroup (Response &&r)
 Construct from a single response. More...
 
template<typename... Parameters>
void operator() (Parameters &&...params)
 Add a new response to the list, after constructing it. More...
 
void operator() (ResponseGroup &&)
 Merge members from another ResponseGroup. More...
 
void transmit (class PianodService &) const
 Transmit a group of response messages to all nodes on a service, using the appropriate protocol for each node. More...
 
void transmitLine (PianodConnection &, int offset=Response::TransmitUnaltered) const
 Transmit a group of responses to the client. More...
 
void transmit (class PianodConnection &) const
 Transmit a group of response messages to a single node using the node's selected protocol. More...
 

Private Member Functions

Parsnip::Data serializeReply () const
 Format successes or diagnostics for JSON transmission. More...
 
Parsnip::Data serializeData (const User *) const
 Format a record's worth of reponses for JSON protocol. More...
 
Parsnip::Data serializeHomogenousData (const User *) const
 Format a homogenous list of responses as a series JSON records. More...
 
Parsnip::Data serializeEvents (bool, const User *) const
 Re-sort messages to be broadcast into categories: More...
 
void transmitLine (class PianodService &) const
 Broadcast a group of responses to an entire service. More...
 
void transmitJSON (class PianodService &) const
 Transmit a group of responses JSON connection on a service. More...
 

Friends

class ResponseCollector
 

Detailed Description

Container for multiple Responses.

May contain any type, but for data, success and command errors contents should be consistent. Others types may mix. For performance, this avoids copy constructors/adders and provides only move constructors/adders.

Constructor & Destructor Documentation

◆ ResponseGroup() [1/3]

ResponseGroup::ResponseGroup ( )
default

◆ ResponseGroup() [2/3]

ResponseGroup::ResponseGroup ( ResponseGroup &&  )
default

◆ ResponseGroup() [3/3]

ResponseGroup::ResponseGroup ( Response &&  r)
inline

Construct from a single response.

Member Function Documentation

◆ operator()() [1/2]

template<typename... Parameters>
void ResponseGroup::operator() ( Parameters &&...  params)
inline

Add a new response to the list, after constructing it.

◆ operator()() [2/2]

void ResponseGroup::operator() ( ResponseGroup &&  merge_from)

Merge members from another ResponseGroup.

Parameters
merge_fromThe other group.

◆ operator=()

ResponseGroup& ResponseGroup::operator= ( ResponseGroup &&  )
default

◆ serializeData()

Parsnip::Data ResponseGroup::serializeData ( const User user) const
private

Format a record's worth of reponses for JSON protocol.

Returns
A dictionary containing the record's data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serializeEvents()

Parsnip::Data ResponseGroup::serializeEvents ( bool  inline_details,
const User user 
) const
private

Re-sort messages to be broadcast into categories:

  • State updates (such as queue mode has been changed to X)
  • Current song (which could be in state, but isn't).
  • Events (track ended, someone logged in, etc)
  • Spontaneous errors on the server. Much like events, except that they are errors.
    Parameters
    inline_detailsIf true, include user-specific info (ratings).
    userThe user for whom to include details.
    Returns
    A dictionary containing dictionaries for any non-empty categories, suitable for JSON transmission.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serializeHomogenousData()

Parsnip::Data ResponseGroup::serializeHomogenousData ( const User user) const
private

Format a homogenous list of responses as a series JSON records.

Returns
A list containing dictionaries, each with their one data item.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serializeReply()

Parsnip::Data ResponseGroup::serializeReply ( ) const
private

Format successes or diagnostics for JSON transmission.

Returns
A list containing the responses.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transmit() [1/2]

void ResponseGroup::transmit ( class PianodConnection destination) const

Transmit a group of response messages to a single node using the node's selected protocol.

Parameters
destinationThe node to direct the responses to.
Here is the call graph for this function:

◆ transmit() [2/2]

void ResponseGroup::transmit ( class PianodService destination) const

Transmit a group of response messages to all nodes on a service, using the appropriate protocol for each node.

Parameters
destinationThe service to direct the responses to.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transmitJSON()

void ResponseGroup::transmitJSON ( class PianodService destination) const
private

Transmit a group of responses JSON connection on a service.

If the responses include the current song, follow up with user-specific ratings and actions.

Parameters
destinationThe service to which to send responses.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transmitLine() [1/2]

void ResponseGroup::transmitLine ( class PianodService service) const
private

Broadcast a group of responses to an entire service.

Parameters
serviceThe service whose clients to send to.
Here is the caller graph for this function:

◆ transmitLine() [2/2]

void ResponseGroup::transmitLine ( PianodConnection there,
int  offset = Response::TransmitUnaltered 
) const

Transmit a group of responses to the client.

Parameters
thereThe target to send to.
offsetIf unspecified, sends messages as-is. Set to TransmitAsDiagnostic to send command error messages as diagnostics.

Friends And Related Function Documentation

◆ ResponseCollector

friend class ResponseCollector
friend

The documentation for this class was generated from the following files: