<h1>HOWTO WRITE an APPLICATION above AGL FRAMEWORK</h1>
<pre><code>version: 1
-Date: 29 mai 2016
+Date: 30 mai 2016
Author: José Bollo
</code></pre>
<p><ul>
<li><a href="#HOWTO.WRITE.an.APPLICATION.above.AGL.FRAMEWORK">HOWTO WRITE an APPLICATION above AGL FRAMEWORK</a>
<ul>
- <li><a href="#Writing.a.C.application">Writing a C application</a></li>
+ <li><a href="#Languages.for.writing.Applications">Languages for writing Applications</a>
+ <ul>
+ <li><a href="#Writing.an.HTML5.application">Writing an HTML5 application</a></li>
+ <li><a href="#Writing.a.Qt.application">Writing a Qt application</a></li>
+ <li><a href="#Writing.a.C.application">Writing a C application</a></li>
+ </ul>
+ </li>
+ <li><a href="#Handling.sessions.within.applications">Handling sessions within applications</a>
+ <ul>
+ <li><a href="#Handling.sessions">Handling sessions</a></li>
+ <li><a href="#Exchanging.tokens">Exchanging tokens</a></li>
+ </ul>
+ </li>
</ul>
</li>
</ul></p>
+<a name="Languages.for.writing.Applications"></a>
+<h2>Languages for writing Applications</h2>
+
+<a name="Writing.an.HTML5.application"></a>
+<h3>Writing an HTML5 application</h3>
+
+<p>Developpers of HTML5 applications (client side) can easyly create
+applications for AGL framework using their prefered
+HTML framework.</p>
+
+<p>Developpers can also create powerful server side plugins to improve
+their application. This server side plugin should return the mime-type
+application/json and can be accessed either by HTTP or by Websockets.</p>
+
+<p>In a near future, the JSON-RPC protocol will be available together
+with the current x-afb-json1 protocol.</p>
+
+<p>Two examples of HTML5 applications are given:</p>
+
+<ul>
+<li><p><a href="https://github.com/iotbzh/afb-client">afb-client</a> a simple “hello world” application</p></li>
+<li><p><a href="https://github.com/iotbzh/afm-client">afm-client</a> a simple “Home screen” application</p></li>
+</ul>
+
+
+<a name="Writing.a.Qt.application"></a>
+<h3>Writing a Qt application</h3>
+
+<p>Writing Qt applications is also possible because Qt offers APIs to
+make HTTP queries and to connect using WebSockets.</p>
+
+<p>It is even possible to write a QML application.
+It is demontrated by the sample application token-websock:</p>
+
+<ul>
+<li><a href="https://github.com/iotbzh/afb-daemon/blob/master/test/token-websock.qml">token-websock</a>
+a simple “hello world” application in QML</li>
+</ul>
+
+
<a name="Writing.a.C.application"></a>
-<h2>Writing a C application</h2>
+<h3>Writing a C application</h3>
<p>C applications can use the binder afb-daemon through a websocket connection.</p>
<p>The current implementation use libsystemd and file descriptors.
This may be changed in the future to also support secure sockets
and being less dependant of libsystemd.</p>
+
+<a name="Handling.sessions.within.applications"></a>
+<h2>Handling sessions within applications</h2>
+
+<p>Applications must be aware of the the features session and token
+when they interact with the binder afb-daemon.</p>
+
+<p>Applications are communicating with their binder afb-daemon using
+a network connection or a kind of network connection (unix domain
+socket isn’t currently implemented but could be used in near future).
+Also, HTTP protocol is not a connected protocol. It means that
+the socket connection can not be used to authenticate a client.</p>
+
+<p>For this reason, the binder should authenticate the application
+by using a commonly shared secret named token and the identification
+of the client named session.</p>
+
+<a name="Handling.sessions"></a>
+<h3>Handling sessions</h3>
+
+<p>Plugins and features of the binder need to keep track of the client
+instances. In principle, a binder afb-daemon is launched by application
+instance. But for services, a binder</p>
+
+<a name="Exchanging.tokens"></a>
+<h3>Exchanging tokens</h3>
+
+<p>At start, the framework communicate a common secret to both the binder
+and its client: the application. This initial secret is the
+initial token.</p>
+
+<p>For each of its client application, the binder manages a current active
+token. The initial token is the default active token. It is the expected
+token for new clients.</p>
</body>
</html>