diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-06-10 13:49:34 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-06-10 13:49:34 +0200 |
commit | 17b196f1326d6b6c249d44b8744d73d7bba12d7a (patch) | |
tree | 6592d70b095c010cf726ac27ad51fd6ca86cc61a /doc/afb-application-writing.html | |
parent | 6518887513840471ea9c5af7e534787717e6bd82 (diff) |
Improves documentation
The script updt.sh is revisited to generate better the
meta data.
The format of events is documented.
Change-Id: I3bb7347f3ac0f660196a25a4c0c0432848fe4168
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'doc/afb-application-writing.html')
-rw-r--r-- | doc/afb-application-writing.html | 75 |
1 files changed, 61 insertions, 14 deletions
diff --git a/doc/afb-application-writing.html b/doc/afb-application-writing.html index b394e6b9..1f1fcc1c 100644 --- a/doc/afb-application-writing.html +++ b/doc/afb-application-writing.html @@ -5,17 +5,38 @@ <meta name="generator" content="pandoc"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <meta name="author" content="José Bollo"> + <meta name="author" content="Fulup Ar Foll"> <title>HOWTO WRITE an APPLICATION above AGL FRAMEWORK</title> <style type="text/css">code{white-space: pre;}</style> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> + <style type="text/css"> +table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode { + margin: 0; padding: 0; vertical-align: baseline; border: none; } +table.sourceCode { width: 100%; line-height: 100%; } +td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; } +td.sourceCode { padding-left: 5px; } +code > span.kw { color: #007020; font-weight: bold; } +code > span.dt { color: #902000; } +code > span.dv { color: #40a070; } +code > span.bn { color: #40a070; } +code > span.fl { color: #40a070; } +code > span.ch { color: #4070a0; } +code > span.st { color: #4070a0; } +code > span.co { color: #60a0b0; font-style: italic; } +code > span.ot { color: #007020; } +code > span.al { color: #ff0000; font-weight: bold; } +code > span.fu { color: #06287e; } +code > span.er { color: #ff0000; font-weight: bold; } + </style> <link rel="stylesheet" href="doc.css"> </head> <body> <header> <h1 class="title">HOWTO WRITE an APPLICATION above AGL FRAMEWORK</h1> <h2 class="author">José Bollo</h2> +<h2 class="author">Fulup Ar Foll</h2> <h3 class="date">09 juin 2016</h3> </header> <nav id="TOC"> @@ -32,10 +53,16 @@ <li><a href="#example-of-session-management">Example of session management</a></li> </ul></li> <li><a href="#format-of-replies">Format of replies</a><ul> +<li><a href="#template">Template</a></li> <li><a href="#field-jtype">Field jtype</a></li> <li><a href="#field-request">Field request</a></li> <li><a href="#field-response">Field response</a></li> -<li><a href="#template">Template</a></li> +</ul></li> +<li><a href="#format-of-events">Format of events</a><ul> +<li><a href="#template-1">Template</a></li> +<li><a href="#field-jtype-1">Field jtype</a></li> +<li><a href="#field-event">Field event</a></li> +<li><a href="#field-data">Field data</a></li> </ul></li> </ul></li> </ul> @@ -130,6 +157,9 @@ Author: José Bollo</code></pre> } }</code></pre> <h4 id="using-afb-client-demo">Using afb-client-demo</h4> +<blockquote> +<p>The program is packaged within AGL in the rpm <strong>libafbwsc-dev</strong></p> +</blockquote> <p>Here is an example of exchange using <strong>afb-client-demo</strong>:</p> <pre><code>$ afb-client-demo ws://localhost:1234/api?token=123456 auth connect @@ -155,6 +185,19 @@ ON-REPLY 1:auth/check: {"jtype":"afb-reply","request&qu <h2 id="format-of-replies">Format of replies</h2> <p>Replies use javascript object returned as serialized JSON.</p> <p>This object contains at least 2 mandatory fields of name <strong>jtype</strong> and <strong>request</strong> and one optional field of name <strong>response</strong>.</p> +<h3 id="template">Template</h3> +<p>This is a template of replies:</p> +<pre class="sourceCode json"><code class="sourceCode json"><span class="fu">{</span> + <span class="dt">"jtype"</span><span class="fu">:</span> <span class="st">"afb-reply"</span><span class="fu">,</span> + <span class="dt">"request"</span><span class="fu">:</span> <span class="fu">{</span> + <span class="dt">"status"</span><span class="fu">:</span> <span class="st">"success"</span><span class="fu">,</span> + <span class="dt">"info"</span><span class="fu">:</span> <span class="st">"informationnal text"</span><span class="fu">,</span> + <span class="dt">"token"</span><span class="fu">:</span> <span class="st">"e83b36f8-d945-463d-b983-5d8ed73ba52"</span><span class="fu">,</span> + <span class="dt">"uuid"</span><span class="fu">:</span> <span class="st">"5fcc3f3d-4b84-4fc7-ba66-2d8bd34ae7d1"</span><span class="fu">,</span> + <span class="dt">"reqid"</span><span class="fu">:</span> <span class="st">"application-generated-id-23456"</span> + <span class="fu">},</span> + <span class="dt">"response"</span><span class="fu">:</span> <span class="er">....any</span> <span class="er">response</span> <span class="er">object....</span> +<span class="fu">}</span></code></pre> <h3 id="field-jtype">Field jtype</h3> <p>The field <strong>jtype</strong> must have a value of type string equal to <strong>"afb-reply"</strong>.</p> <h3 id="field-request">Field request</h3> @@ -171,18 +214,22 @@ ON-REPLY 1:auth/check: {"jtype":"afb-reply","request&qu <p><strong>reqid</strong> is of type string. It is sent in response to HTTP requests that added a parameter of name <strong>reqid</strong> or <strong>x-afb-reqid</strong> at request time. Value returns in the reply has the exact same value as the one received in the request.</p> <h3 id="field-response">Field response</h3> <p>This field response optionally contains an object returned when request succeeded.</p> -<h3 id="template">Template</h3> -<p>This is a template of replies:</p> -<pre><code>{ - "jtype": "afb-reply", - "request": { - "status": "success", - "info": "informationnal text", - "token": "e83b36f8-d945-463d-b983-5d8ed73ba52", - "uuid": "5fcc3f3d-4b84-4fc7-ba66-2d8bd34ae7d1", - "reqid": "application-generated-id-23456" - }, - "response": ....any response object.... -}</code></pre> +<h2 id="format-of-events">Format of events</h2> +<p>Events are javascript object serialized as JSON.</p> +<p>This object contains at least 2 mandatory fields of name <strong>jtype</strong> and <strong>event</strong> and one optional field of name <strong>data</strong>.</p> +<h3 id="template-1">Template</h3> +<p>Here is a template of event:</p> +<pre class="sourceCode json"><code class="sourceCode json"><span class="fu">{</span> + <span class="dt">"jtype"</span><span class="fu">:</span> <span class="st">"afb-event"</span><span class="fu">,</span> + <span class="dt">"event"</span><span class="fu">:</span> <span class="st">"sample_api_name/sample_event_name"</span><span class="fu">,</span> + <span class="dt">"data"</span><span class="fu">:</span> <span class="er">...any</span> <span class="er">event</span> <span class="er">data...</span> +<span class="fu">}</span></code></pre> +<h3 id="field-jtype-1">Field jtype</h3> +<p>The field <strong>jtype</strong> must have a value of type string equal to <strong>"afb-event"</strong>.</p> +<h3 id="field-event">Field event</h3> +<p>The field <strong>event</strong> carries the event's name.</p> +<p>The name of the event is made of two parts separated by a slash: the name of the name of the API that generated the event and the name of event within the API.</p> +<h3 id="field-data">Field data</h3> +<p>This field data if present holds the data carried by the event.</p> </body> </html> |