|
pianod2
multisource multiuser scriptable networked music player
|
Connection to a pianod client, along with context and state of that connection. More...
#include <connection.h>


Public Member Functions | |
| virtual | ~PianodConnection () override |
| bool | transmitJSON () const |
| void | close_after_events () |
| Close after events are handled, or now if not waiting on one. More... | |
| bool | authenticated (void) const |
| Determine if the connection is authenticated, i.e., has a user. More... | |
| ResponseGroup | updateConnection () |
| std::string | username (void) const |
| Media::Source *const | source () const |
| Get the connection's selected source. More... | |
| ResponseGroup | source (Media::Source *const source, bool announce=true) |
| Set the selected source. More... | |
| bool | haveRank (Rank rank) const |
| Rank | effectiveRank (void) const |
| Get connected user's rank. More... | |
| bool | havePrivilege (Privilege priv) const |
| Determine if the user has a privilege. More... | |
| void | waitForEventWithOptions (WaitEvent::Type type, const Parsnip::Data &options, const void *detail) |
| Interpret options and begin waiting for an event on a connection. More... | |
| void | waitForEvent (WaitEvent::Type type, const void *detail) |
| Begin waiting for an event on a connection. More... | |
| void | event (WaitEvent::Type type, const void *detail, RESPONSE_CODE reply) |
| Process an event for a connection. More... | |
| void | checkTimeouts () |
| Check if a pending event has timed out. More... | |
| ResponseGroup | sendSelectedSource () const |
| Report the selected source to the connection. More... | |
| ResponseGroup | sendEffectivePrivileges () const |
| Transmit the user's effective privileges. More... | |
| void | announceToRoom (ResponseGroup &&announcement) const |
| Send some messages to all users in a room. More... | |
| void | announceToAll (ResponseGroup &&announcement) const |
| Broadcast some messages to all connected sessions, all rooms. More... | |
| PianodService & | service (void) const |
Public Member Functions inherited from Football::Connection | |
| ServiceBase * | service (void) const |
| Get a connection's parent service. More... | |
| virtual | ~Connection () override |
| virtual ssize_t | conditional_print (bool(*callback)(FB_CONNECTION *), const std::string &message) override |
| Send a message to some output queues depending on the callback function return value. More... | |
| bool | transfer (ServiceBase *service, bool invokeNewConnectionHandler=false) |
| Transfer a connection to another service. More... | |
| void | close (void) |
| Initiate connection closure. More... | |
| void | acceptInput (bool mode) |
| Control acceptance of input. More... | |
Public Member Functions inherited from Football::Thingie | |
| virtual | ~Thingie () |
| ssize_t | print (const std::string &message) |
| Add a string to the output queues. More... | |
| ssize_t | conditional_broadcast (bool(*callback)(FB_CONNECTION *), const std::string &message) |
| Send a message to some output queues depending on the callback function return value. More... | |
| ssize_t | printf (const char *format,...) |
| Add messages to output queues. More... | |
| ssize_t | vprintf (const char *format, va_list parameters) |
| ssize_t | bprintf (const char *format,...) |
| ssize_t | bvprintf (const char *format, va_list parameters) |
| ssize_t | cbprintf (bool(*callback)(FB_CONNECTION *), const char *format,...) |
| ssize_t | cbvprintf (bool(*callback)(FB_CONNECTION *), const char *format, va_list parameters) |
| virtual std::streamsize | xsputn (const char_type *data, std::streamsize count) override |
| virtual int_type | overflow (int_type c) override |
Static Public Member Functions | |
| static bool | json_connections_only (FB_CONNECTION *) |
| Callback function used to identify JSON connections. More... | |
| static bool | line_connections_only (FB_CONNECTION *) |
| Callback function used to identify line protocol connections. More... | |
Public Attributes | |
| User * | user = nullptr |
Private Member Functions | |
| virtual void | newConnection (const FB_EVENT *event) override |
| Invoked when a new connection has arrived/greeted. More... | |
| virtual void | connectionClose (const FB_EVENT *event) override |
| Invoked when a connection is closing. More... | |
| virtual void | inputReceived (const FB_EVENT *event) override |
| Invoked when a completed message is received. More... | |
Private Attributes | |
| Media::Source * | _source = nullptr |
| The current source. More... | |
| WaitEvent | pending |
| An event this connection is waited for. More... | |
| bool | use_json = false |
| Set to true if protocol is JSON. More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from Football::Connection | |
| static Connection * | tryGetFromOld (FB_CONNECTION *connection) |
Connection to a pianod client, along with context and state of that connection.
|
overridevirtual |
| void PianodConnection::announceToAll | ( | ResponseGroup && | announcements | ) | const |
Broadcast some messages to all connected sessions, all rooms.
If announcing user actions is disabled, any such messages are deleted.
| announcements | The announcements to send. |


| void PianodConnection::announceToRoom | ( | ResponseGroup && | announcements | ) | const |
Send some messages to all users in a room.
If announcing user actions is disabled, any such messages are deleted.
| announcements | The announcements to send. |


|
inline |
Determine if the connection is authenticated, i.e., has a user.

| void PianodConnection::checkTimeouts | ( | ) |
Check if a pending event has timed out.
If so, fire it with failure. Otherwise, check then pending event for a closer next timeout time.

| void PianodConnection::close_after_events | ( | ) |
Close after events are handled, or now if not waiting on one.


|
overrideprivatevirtual |
Invoked when a connection is closing.
Corresponds to FB_EVENT_CLOSE event. This is the last notification/event for a connection before it closes.
| event | Closing connection details. |
Reimplemented from Football::Connection.

| Rank PianodConnection::effectiveRank | ( | void | ) | const |
Get connected user's rank.


| void PianodConnection::event | ( | WaitEvent::Type | type, |
| const void * | detail, | ||
| RESPONSE_CODE | reply | ||
| ) |
Process an event for a connection.
If waiting for the event, the status is announced and input is resumed. If not waiting, or waiting for a different event, nothing happens.
| type | The type of event occurring. |
| detail | A pointer representing a specific event instance. |
| reply | The status to report if the event applies to the connection. |


| bool PianodConnection::havePrivilege | ( | Privilege | priv | ) | const |
Determine if the user has a privilege.
Visitors cannot be assigned privileges but they may be implied by rank.
| priv | The privilege to check. |


| bool PianodConnection::haveRank | ( | Rank | rank | ) | const |


|
overrideprivatevirtual |
Invoked when a completed message is received.
Corresponds to FB_EVENT_INPUT event.
| event | Details of the message received. |
Reimplemented from Football::Connection.

|
static |
|
static |
Callback function used to identify line protocol connections.
| conn | A football connection. |


|
overrideprivatevirtual |
Invoked when a new connection has arrived/greeted.
Corresponds to FB_EVENT_CONNECT.
| event | The new connection details, or a nullptr for transferred connections. |
Reimplemented from Football::Connection.

| ResponseGroup PianodConnection::sendEffectivePrivileges | ( | ) | const |
Transmit the user's effective privileges.


| ResponseGroup PianodConnection::sendSelectedSource | ( | ) | const |
Report the selected source to the connection.


|
inline |


|
inline |
Get the connection's selected source.

| ResponseGroup PianodConnection::source | ( | Media::Source *const | source, |
| bool | announce = true |
||
| ) |
Set the selected source.
| source | The new source. |
| announce | True (or omitted) to announce the new source in protocol. |

|
inline |

| ResponseGroup PianodConnection::updateConnection | ( | ) |


|
inline |


| void PianodConnection::waitForEvent | ( | WaitEvent::Type | type, |
| const void * | detail | ||
| ) |
Begin waiting for an event on a connection.
| type | The type of event to wait for. |
| detail | A pointer representing a specific event instance to wait for. |


| void PianodConnection::waitForEventWithOptions | ( | WaitEvent::Type | type, |
| const Parsnip::Data & | options, | ||
| const void * | detail | ||
| ) |
Interpret options and begin waiting for an event on a connection.
| type | The type of event to wait for. |
| options | Wait-related details from command line. |
| detail | A pointer representing a specific event instance to wait for. |


|
private |
The current source.
|
private |
An event this connection is waited for.
|
private |
Set to true if protocol is JSON.
| User* PianodConnection::user = nullptr |