Warning, /system/mycroft-gui/transportProtocol.md is written in an unsupported language. File is not indexed.

0001 # ACTIVE SKILLS LIST
0002 The active skill data, described in the section MODELS is mandatory for the rest of the protocol to work. I.e. if some data or an event arrives with namespace "mycroft.weather", the skill id "mycroft.weather" must have been advertised as recently used in the recent skills model beforehand, otherwise all requests on that namespace will be ignored on both client and serverside and considered a protocol error.
0003 Recent skills are ordered from the last used to the oldest, so the first item of the model will always be the the one showing any QML GUI, if available.
0004 
0005 # EVENTS
0006 ```javascript
0007 {
0008     "type": "mycroft.events.triggered"
0009     "namespace": "weather.mycroft"
0010     "event_name": "system.pick",
0011     "parameters": {"item": 3}
0012 }
0013 ```
0014 
0015 * event names that start with "system." are available to all skills, like previous/next/pick. the skill author can have as many custom events as he wants
0016 * same message format goes both ways python->gui and gui->python
0017 
0018 ## SPECIAL EVENT: page_gained_focus
0019 ```javascript
0020 {
0021     "type": "mycroft.events.triggered",
0022     "namespace": "mycroft.weather",
0023     "event_name": "page_gained_focus",
0024     "data": {"number": 0}
0025 }
0026 ```
0027 This event is used when the server wants a page of the gui model of a particular skill to gain user attention focus and become the current active view and "focus of attention" of the user. This event is supported on both directions of communication between server and gui.
0028 The parameter "number" is the position (starting from zero) of the page in the gui model (see the section gui model).
0029 
0030 
0031 # SKILL DATA
0032 
0033 At the center of data sharing there is a key/value dictionary that is kept synchronized between the server and the GUI client.
0034 Values can either be simple strings, numbers and booleans or be more complicated data models as described in the MODELS section.
0035 
0036 ## Sets a new key/value in the sessionData dictionary
0037 Either sets a new key/value pair or replace an existing old value.
0038 ```javascript
0039 {
0040     "type": "mycroft.session.set",
0041     "namespace": "weather.mycroft"
0042     "data": {
0043         "temperature": "28",
0044         "icon": "cloudy",
0045         "forecast": [{...},...] //if it's a list a model gets created, or resetted if it was already existing, see the MODELS section
0046     }
0047 }
0048 ```
0049 
0050 ## Deletes a key/value pair from the sessionData dictionary
0051 ```javascript
0052 {
0053     "type": "mycroft.session.delete",
0054     "namespace": "weather.mycroft"
0055     "property": "temperature"
0056 }
0057 ```
0058 
0059 All properties already in the dictionary need to be sent as soon as a new client connects to the web socket
0060 
0061 The exact message format would be in both direction both server->gui and gui->server
0062 
0063 
0064 # MODELS
0065 Models are for both skill data and active skills, distinction is just between "namespace": "mycroft.system.active_skills" and "namespace": "mycroft.weather"
0066 All operations have a type which starts by "type": "mycroft.session.list."
0067 
0068 The format of the data passed via the socket is of an ordered map
0069 ```javascript
0070 [
0071 {
0072   "key1": "value1",
0073   "key2": "value2"
0074 },
0075 {
0076   "key1": "value3",
0077   "key2": "value4"
0078 }
0079 ]
0080 ```
0081 
0082 It must always be an array, even if contains a single item, and each item must contain the exact same set of keys, even if some of them could be empty.
0083 If subsequent inserts of items will contain a different set of keys, or toehr keys more, those new keys will be ignored by the GUI.
0084 
0085 ## Inserts new items at position
0086 ```javascript
0087 {
0088     "type": "mycroft.session.list.insert",
0089     "namespace": "mycroft.system.active_skills" // skill: mycroft.weather
0090     "property": "forecast" //the key of the main data map this list in contained into
0091     "position": 2
0092     "values": [{"date": "tomorrow", "temperature" : 13, ...}, ...] //values must always be in array form
0093 }
0094 ```
0095 
0096 Values is an ordered dict, for a shopping cart it would need multiple roles like product name, price, image
0097 
0098 ## Updates item values starting at the given position, as many items as there are in the array
0099 ```javascript
0100 {
0101     "type": "mycroft.session.list.update",
0102     "namespace": "mycroft.system.active_skills" // skill: mycroft.weather
0103     "property": "forecast" //in the future this can become a path if we want lists of lists
0104     "position": 2
0105     "values": [{"date": "tomorrow", "temperature" : 13, ...}, ...] //values must always be in array form
0106 }
0107 ```
0108 
0109 ## Move items within the list
0110 ```javascript
0111 {
0112     "type": "mycroft.session.list.move",
0113     "namespace": "mycroft.system.active_skills" // skill: mycroft.weather
0114     "property": "forecast"
0115     "from": 2
0116     "to": 5
0117     "items_number": 2 //optional in case we want to move a big chunk of list at once
0118 }
0119 ```
0120 
0121 ## Remove items from the list
0122 ```javascript
0123 {
0124     "type": "mycroft.session.list.remove",
0125     "namespace": "mycroft.system.active_skills" // skill: mycroft.weather
0126     "property": "forecast" //in the future this can become a path if we want lists of lists
0127     "position": 2
0128     "items_number": 5 //optional in case we want to get rid a big chunk of list at once
0129 }
0130 ```
0131 
0132 # GUI MODEL
0133 Each active skill is associated with a model with urls to the QML files of all gui items that are supposed to be visible.
0134 
0135 ## Inserts new GUI items at position
0136 ```javascript
0137 {
0138     "type": "mycroft.gui.list.insert",
0139     "namespace": "mycroft.weather"
0140     "position": 2
0141     "values": [{"url": "file://..../currentWeather.qml"}, ...] //values must always be in array form
0142 }
0143 ```
0144 
0145 ## Move items within the list
0146 ```javascript
0147 {
0148     "type": "mycroft.gui.list.move",
0149     "namespace": "mycroft.weather"
0150     "from": 2
0151     "to": 5
0152     "items_number": 2 //optional in case we want to move a big chunk of list at once
0153 }
0154 ```
0155 
0156 ## Remove items from the list
0157 ```javascript
0158 {
0159     "type": "mycroft.gui.list.remove",
0160     "namespace": "mycroft.weather"
0161     "position": 2
0162     "items_number": 5 //optional in case we want to get rid a big chunk of list at once
0163 }
0164 ```
0165