afb-hreq.c: fix etag size (fixes stack smashing detected by stack protector)
[src/app-framework-binder.git] / doc / afb-plugins-overview.md
1 # Overview of plugins shipped with AFB-Daemon
2     Version: 1
3     Date:    30 mai 2016
4     Author:  Manuel Bachmann
5
6
7 ## List of plugins
8 Here are the plugins shipped in the source tree:
9
10 * Hello World
11 * Authentication
12 * Tic Tac Toe
13 * Audio _(2 backends: ALSA/PulseAudio)_
14 * Media _(1 backend: Rygel UPnP)_
15
16 All plugins may not be built, depending on the development libraries present on the system at build time.
17
18
19 ## Detail of plugins
20
21 ### Hello World
22
23 A sample Hello World plugin for demonstration and learning purposes.
24
25 This plugin provides a few unauthenticated requests, all beginning with "ping", to demonstrate basic binder capabilities.
26
27 **Verbs**:
28
29 * _ping:_ returns a success response
30 * _pingfail:_ returns a failure response
31 * _pingnull:_ returns a success response, with an empty JSON response field
32 * _pingbug:_ does a memory violation (intercepted by the binder)
33 * _pingJson:_ returns a success response, with a complex JSON response field
34 * _pingevent:_ broadcasts a global event
35
36 <br />
37
38
39 ### Authentication
40
41 An sample Authentication plugin for demonstration purposes.
42
43 This plugin provides a few requests to demonstrate the binder's token-based security mechanism.
44
45 Calling "_connect_" with a security token will initiate a session, calling "_refresh_" will issue a new token and invalidate the previous one, calling "_logout_" will invalidate all tokens and close the session.
46
47 **Verbs**:
48
49 * _ping:_ returns a success response
50 * _connect:_ creates a session and returns a new token
51 * _refresh:_ returns a new token
52 * _check:_ verifies the passed token is valid
53 * _logout:_ closes the session
54
55 <br />
56
57
58 ### Tic Tac Toe
59
60 A sample Tic Tac Toe game plugin.
61
62 This plugin provides an interactive Tic Tac Toe game where the binder returns the grid as a JSON response. 
63
64 **Verbs**:
65
66 * _new:_ starts a new game
67 * _play:_ asks the server to play
68 * _move:_ gives a client move
69 * _board:_ gets the current board state, as a JSON structure
70 * _level_: sets the server level
71 * _join_: joins an existing board
72 * _undo_: undo the last move
73 * _wait_: wait for a move
74
75 <br />
76
77
78 ### Audio
79
80 A sample Audio plugin with 2 backends:
81
82 * ALSA (mandatory)
83 * PulseAudio (optional)
84
85 This plugin is able to initialize a specific soundcard, define volume levels, channels (mono/stereo...), mute sound, and play a 22,050 Hz PCM stream.
86
87 **Verbs**:
88
89 * _ping:_ returns a success response
90 * _init:_ initializes backend, on the "default" sound card
91 * _volume:_ gets or sets volume, in % (0-100)
92 * _channels:_ gets or sets channels count (1-8)
93 * _mute:_ gets or sets the mute status (on-off)
94 * _play_: gets or sets the playing status (on-off)
95
96 _(if PulseAudio development libraries are not found at build time, only ALSA will be available)_
97
98 _(if a PulseAudio server is not found at runtime, the plugin will dynamically fall back to ALSA)_
99
100 _(a specifc backend can be forced by using this syntax before running afb-daemon : **$ export AFB_AUDIO_OUTPUT=Alsa**)_
101
102 <br />
103
104
105 ### Media
106
107 A sample Media Server plugin with 1 backend:
108
109  * Rygel
110
111 This plugin is able to detect a local Rygel UPnP media server, list audio files, select an audio file for playback, play/pause/seek in this file, upload an audio file to the server.
112
113 **Verbs**:
114
115 * _ping:_ returns a success response
116 * _init:_ initializes backend, looking for an active local UPnP server
117 * _list:_ returns list of audio files, as a JSON structure
118 * _select:_ select an audio files, by index number (001-...)
119 * _play:_ plays the currently selected audio file
120 * _stop:_ stops the currently selected audio file
121 * _pause:_ pauses the currently selected audio file
122 * _seek:_ seeks in the currently selected audio file, in seconds
123 * _upload:_ uploads an audio file, with a POST request
124
125 _(if GUPnP/GSSDP development libraries are not fund at build time, this plugin will not be built)_
126
127 <br />
128
129
130 ---
131 <br />
132
133 Sample command-line applications: _afb-client-demo_ (built by default)
134
135 Sample HTML5 applications: **test/*.html**, **[afb-client](https://github.com/iotbzh/afb-client)**, **[afb-radio](https://github.com/iotbzh/afb-radio)**
136
137 Sample Qt/QML applications: *test/token-websock.qml*