Differences
This shows you the differences between two versions of the page.
hakke [2015/10/30 16:52] mroriz [Download] |
hakke [2017/07/21 03:08] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{template>: | ||
- | | name=Hakke | ||
- | | version=0.1 | ||
- | | accountable=Marcos Roriz | ||
- | | depdency= | ||
- | }} | ||
- | |||
- | ====== Hakke ====== | ||
- | Hakke provides a Gateway between [[SDDL]] and Web applications. Specifically, | ||
- | |||
- | ===== Usage ===== | ||
- | ==== Receiving Messages in Hakke ==== | ||
- | Hakke can receive and send message from and to the SDDL Core. To receive and process a message Hakke require that developers register a handling function. These functions are added to a global pre-defined array of functions named '' | ||
- | |||
- | For example, to add a function that treats '' | ||
- | |||
- | <code javascript> | ||
- | scriptFunctions[" | ||
- | var lat = data.lat; | ||
- | var lng = data.lng; | ||
- | //... | ||
- | } | ||
- | </ | ||
- | |||
- | Include this code in a JavaScript file or append in the '' | ||
- | |||
- | ==== Sending Messages to Hakke ==== | ||
- | SDDL Core applications can send ApplicationMessages to Hakke. To do that, the content object in the message must be a JSON String. There are numerous JSON libraries for Java, in the following code we will use [[https:// | ||
- | |||
- | <code java> | ||
- | JSONObject jsonMSG = new JSONObject(); | ||
- | jsonMSG.put(" | ||
- | jsonMSG.put(" | ||
- | jsonMSG.put(" | ||
- | jsonMSG.put(" | ||
- | jsonMSG.obj.put(" | ||
- | jsonMSG.obj.put(" | ||
- | | ||
- | ApplicationMessage msg = new ApplicationMessage(); | ||
- | msg.setContentObject(jsonMSG.toString()); | ||
- | msg.setPayloadType(PayloadSerialization.JSON); | ||
- | |||
- | nodeCon.sendMessage(msg); | ||
- | </ | ||
- | ===== Architecture ===== | ||
- | Hakke uses the Play Framework. A difference between Play and other Web famework it that, by default, it comes with a Web Server. This feature enables Play, and by extension Hakke, to be self-contained. As a Web Framework Hakke treats and process HTTP request, however we need to receive and send from/to SDDL Core to the Web Browser. Play has the concept of global entities, //i.e.//, entities that will be available throughout all the web server lifecycle. We wrap a SDDL DataReader and DataWriter in a global entity called '' | ||
- | |||
- | Whenever Hakke loads the index page it creates a [[wp> | ||
- | |||
- | The browser received the sent message in a pre-defined Hakke JavaScript routine. This routine unwraps the message and parse it as a JSON variable '' | ||
- | |||
- | {{: | ||
- | |||
- | |||
- | ===== Download ===== | ||
- | - First, download the [[Download|'' | ||
- | - Download [[https:// | ||
- | - Hakke depends on contextnet, thus, install | ||
- | <code bash> $ mvn install: | ||
- | - Now, download the [[https:// | ||
- | - [[https:// | ||
- | - Unpack Hakke. To run the application, | ||
- | <code bash> $ activator run </ | ||
- | |||