pianod2
multisource multiuser scriptable networked music player
Classes | Namespaces | Functions | Variables
response.h File Reference

Send messages of various kinds to clients. More...

#include <config.h>
#include <ctime>
#include <string>
#include <vector>
#include <ostream>
#include <exception>
#include <memory>
#include "fundamentals.h"
#include "musictypes.h"
#include "retainer.h"
Include dependency graph for response.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Response
 Type combining RESPONSE_CODE with a value or explanation: More...
 
class  ResponseGroup
 Container for multiple Responses. More...
 
class  ResponseCollector
 A response collector/aggregator. More...
 
class  CommandReply
 This class is derived from ResponseCollector and adds success/failure adder functions and a few variables to support this. More...
 
class  DataResponse
 This class is derived from ResponseCollector, and adds no member variables but adds data adder functions. More...
 

Namespaces

 Football
 Football C++ connections, services and parsers.
 
 Parsnip
 Serialization and parsing library.
 
 JSON
 
 JSON::Key
 

Functions

const char * ResponseText (RESPONSE_CODE code)
 Retrieve the text for a success, failure, event or data message. More...
 
const char * JSONFieldName (RESPONSE_CODE code)
 Retrieve the JSON text for a response. More...
 
std::string format_duration (time_t duration, int minute_places=1)
 Format a duration as minutes and seconds. More...
 
Football::Thingieoperator<< (Football::Thingie &there, const Response &response)
 Use << as output operator for Response. More...
 
Football::Thingieoperator<< (Football::Thingie *there, const Response &response)
 Use << as output operator for Response. More...
 
PianodConnectionoperator<< (PianodConnection &there, const Response &response)
 Use << as output operator for responses. More...
 
PianodConnectionoperator<< (PianodConnection *there, const Response &response)
 Use << as output operator for Response. More...
 
class PianodConnectionoperator<< (class PianodConnection &there, const ResponseCollector &response)
 
class PianodConnectionoperator<< (class PianodConnection *there, const ResponseCollector &response)
 Use << as output operator for ResponseCollector. More...
 
void sendUpdatedRatings (PianodConnection &conn, const PianodSong *song, CommandReply *reply)
 Send updated ratings. More...
 

Variables

const char * JSON::Key::PlayDuration = Music::Key::SongDuration
 
const char * JSON::Key::PlayPoint = "timeIndex"
 
const char * JSON::Key::PlayRemaining = "timeRemaining"
 

Detailed Description

Send messages of various kinds to clients.

Function Documentation

◆ format_duration()

std::string format_duration ( time_t  duration,
int  minute_places 
)

Format a duration as minutes and seconds.

Parameters
durationThe duration.
minute_placesThe minimum number of digits to use for minutes. If less than this are required, the duration is zero-padded.
Returns
The duration in m:ss format.
Here is the caller graph for this function:

◆ JSONFieldName()

const char* JSONFieldName ( RESPONSE_CODE  code)

Retrieve the JSON text for a response.

Parameters
codeThe number of the response. For status or error text use ResponseText.
Returns
The name of the field or related text.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator<<() [1/6]

class PianodConnection& operator<< ( class PianodConnection there,
const ResponseCollector response 
)

◆ operator<<() [2/6]

class PianodConnection& operator<< ( class PianodConnection there,
const ResponseCollector response 
)
inline

Use << as output operator for ResponseCollector.

◆ operator<<() [3/6]

Football::Thingie& operator<< ( Football::Thingie there,
const Response response 
)
inline

Use << as output operator for Response.

Here is the call graph for this function:

◆ operator<<() [4/6]

Football::Thingie& operator<< ( Football::Thingie there,
const Response response 
)
inline

Use << as output operator for Response.

Here is the call graph for this function:

◆ operator<<() [5/6]

PianodConnection& operator<< ( PianodConnection there,
const Response response 
)

Use << as output operator for responses.

Parameters
thereThe place to send the response.
responseThe response or data to send.
Note
This needs to be out-of-line as the header file doesn't know PianodConnection can be used as a Football::Thingie.
Here is the call graph for this function:

◆ operator<<() [6/6]

PianodConnection& operator<< ( PianodConnection there,
const Response response 
)
inline

Use << as output operator for Response.

◆ ResponseText()

const char* ResponseText ( RESPONSE_CODE  response)

Retrieve the text for a success, failure, event or data message.

Parameters
responseThe number of the status or datum.
Returns
The corresponding text.
Here is the caller graph for this function:

◆ sendUpdatedRatings()

void sendUpdatedRatings ( PianodConnection conn,
const PianodSong song,
CommandReply response 
)

Send updated ratings.

Parameters
connThe connection initiating the ratings change.
songThe ratings to send.
responseThe reply in which ratings are inserted.
Here is the call graph for this function:
Here is the caller graph for this function: