Manages all of the protocols that clients may speak.
More...
Go to the source code of this file.
|
| struct | protocol_heartbeat |
| | Useful information about heartbeat timings. More...
|
| |
| struct | protocol_frames |
| | Some protocols (HTTP, looking at you) need a few frames types depending on the type of client they're immediately sending to, so those possiblities are stored here and exposed to all protocols. More...
|
| |
| struct | protocol |
| | What a protocol needs to route messages around. More...
|
| |
|
|
#define | PROTOCOLS_HEARTBEAT "/qio/heartbeat:0=null" |
| | Full heartbeat event that is fired to clients.
|
| |
|
| struct client * | protocols_new_surrogate (struct protocol *prot) |
| | Create a new surrogate client bound to the given protocol. More...
|
| |
| void | protocols_route (struct client *client) |
| | Route a message from a client to the correct protocol handler. More...
|
| |
| void | protocols_send (struct client *client, const gchar *ev_path, const gchar *ev_extra, const evs_cb_t server_cb, const gchar *json) |
| | Write data out to a client, properly framing it as the protocol requires. More...
|
| |
| void | protocols_closed (struct client *client, guint reason) |
| | Notification that a client was closed. More...
|
| |
| struct protocol_frames * | protocols_bcast (const gchar *ev_path, const gchar *json) |
| | Get an array of framed events, one for each protocol. More...
|
| |
|
void | protocols_bcast_write (struct client *client, const struct protocol_frames *frames) |
| | Writes the broadcast to the given client.
|
| |
|
void | protocols_bcast_free (struct protocol_frames *frames) |
| | Frees up the frames allocated by protocols_bcast().
|
| |
|
void | protocols_heartbeat (struct client *client, const struct protocol_heartbeat *hb) |
| | Run any necessary heartbeating on the given client.
|
| |
|
struct protocol_heartbeat | protocols_heartbeat_get_intervals () |
| | Get the heartbeat intervals that should be used in this round of periodic tasks.
|
| |
|
void | protocols_switch (struct client *client, struct protocol *prot) |
| | Switch a client to a different protocol.
|
| |
|
void | protocols_init () |
| | Setup all protocols and get ready to run.
|
| |
Manages all of the protocols that clients may speak.
- Author
- Andrew Stone andre.nosp@m.w@cl.nosp@m.ovar..nosp@m.com
- Copyright
- 2012-2014 Clear Channel Inc.
If a protocol can handle a client.
| Enumerator |
|---|
| PROT_YES |
Can definitely handle the client.
|
| PROT_MAYBE |
Might be able to handle the client, need more data to see.
|
| PROT_NO |
Definitely cannot handle the client.
|
Responses from the route() functions.
| Enumerator |
|---|
| PROT_OK |
Message was handled and routed correctly.
|
| PROT_AGAIN |
Message has not been completely delivered yet, try again with more data.
|
| PROT_FATAL |
The client was killed by the protocol and will not be handled.
|
| struct protocol_frames* protocols_bcast |
( |
const gchar * |
ev_path, |
|
|
const gchar * |
json |
|
) |
| |
Get an array of framed events, one for each protocol.
- Parameters
-
| ev_path | The path of the event |
| json | Data to send |
- Returns
- The frames that can be passed to protocols_bcast_write() to send to a client. Must be freed with protocols_bcast_free() when done.
| void protocols_closed |
( |
struct client * |
client, |
|
|
guint |
reason |
|
) |
| |
Notification that a client was closed.
- Parameters
-
| client | The client that closed |
| reason | What happened to the client |
Create a new surrogate client bound to the given protocol.
- Parameters
-
| prot | The protocol to bind the new client to. |
- Returns
- A quick-event surrogate client bound to the protocol.
| void protocols_route |
( |
struct client * |
client | ) |
|
Route a message from a client to the correct protocol handler.
- Parameters
-
| client | The client ready for routing |
| void protocols_send |
( |
struct client * |
client, |
|
|
const gchar * |
ev_path, |
|
|
const gchar * |
ev_extra, |
|
|
const evs_cb_t |
server_cb, |
|
|
const gchar * |
json |
|
) |
| |
Write data out to a client, properly framing it as the protocol requires.
No data validation is done; anything that is passed is assumed to be valid. Use evs_* functions for friendlier, validated, and more idomatic ways of sending messages.
- Parameters
-
| client | The client to write to |
| ev_path | The path of the event |
| ev_extra | Any extra path segments |
| server_cb | The callback expected on the server |
| json | Data to send with the event. MUST be a properly-formatted JSON string. [not-null] |