|
|
|
# Ismara update checking and messaging between client and server
|
|
|
|
|
|
|
|
- Updates and messages are checked when program starts (at Component.onCompleted)
|
|
|
|
- possible messages
|
|
|
|
- Program updates available
|
|
|
|
- warnings like downtime or security
|
|
|
|
- some other messages like advertising
|
|
|
|
|
|
|
|
Displaying messages are initiated by the client, calling a webservice using ajax. Server returns json formatted reply which is then displayed by the client either using system notifications or internally.
|
|
|
|
|
|
|
|
#### Parameters when calling server
|
|
|
|
|
|
|
|
- version as x.y.zz 1.2.09 without dots: version=1209 (or do we use an "update check" version based on date: ver=20151211 instead)
|
|
|
|
- last seen message number, used to filter possible "other" messages: last=3
|
|
|
|
|
|
|
|
#### reply from the server
|
|
|
|
|
|
|
|
Server will send back reply in json format
|
|
|
|
- status (int)
|
|
|
|
- messages (array)
|
|
|
|
- type (array) 'info' | 'update' | 'warning' (how the message is going to be displayed in the client)
|
|
|
|
- msgTxt (string) (the message to display)
|
|
|
|
- msgId (int) (update the last seen message in the settings)
|
|
|
|
|
|
|
|
example url http://server/messages.php?ver=20151205&last=3
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
|
|
|
"data":[
|
|
|
|
"status": 0,
|
|
|
|
"messages": [
|
|
|
|
{
|
|
|
|
"type": "update",
|
|
|
|
"msgTxt": "There is an update available, click here to download. In this version we've fixed the program to be compatible with 'El Capitan' and Windows 10. Click here for full version info.",
|
|
|
|
"msgId": 5
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "info",
|
|
|
|
"msgTxt": "New versions of genomes available for download in Ismara web site, click here to go directly to download page",
|
|
|
|
"msgId": 6
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Type is
|
|
|
|
- **update** if there's a new version available
|
|
|
|
- **info** if there's something happening which is of interest for the users
|
|
|
|
- **warning** if there's something the users should be aware of, like server outages, security risks etc.
|
|
|
|
|
|
|
|
Update and warning messages bypass the "last seen" message checks and are always sent.
|
|
|
|
|
|
|
|
## Server side structure
|
|
|
|
|
|
|
|
Server reads "message files" based on rules above. These files are named to contain information of their content and if they are "active" or "archived". The content is markdown (or html), which is then formatted to html if needed.
|
|
|
|
|
|
|
|
#### Example of message naming:
|
|
|
|
|
|
|
|
type_id_comment.md
|
|
|
|
|
|
|
|
update_5_20151211.md
|
|
|
|
|
|
|
|
- type is *update* version
|
|
|
|
- message *id* is 5
|
|
|
|
- *comment* tells about what the message is about without opening it. **for update it's also to compare and filter update messages**
|
|
|
|
|
|
|
|
info_6_new-genomes-dec-2015.md
|
|
|
|
|
|
|
|
- type is *info*
|
|
|
|
- message *id* is 6
|
|
|
|
- comment is about new genomes released
|
|
|
|
|
|
|
|
warning_3_el-capitan-breaks-client-2015-10.md_archive
|
|
|
|
|
|
|
|
- type is *warning*
|
|
|
|
- message *id* is 3
|
|
|
|
- it's about El Capitan breaking the client.
|
|
|
|
|
|
|
|
This way we can easily control the content shown to the client. Rename obsolete messages and they are not processed anymore. The efficiency of the script isn't that crucial as there should not be more than few active messages at any time.
|
|
|
|
|
|
|
|
### Functionality of the server script
|
|
|
|
|
|
|
|
- read get parameters
|
|
|
|
- extract client version and last seen message id
|
|
|
|
- read active message files
|
|
|
|
- extract type and id of each message
|
|
|
|
- in case of update message, compare client and message versions
|
|
|
|
- filter other messages based on last seen id
|
|
|
|
- convert markdown message text into html
|
|
|
|
- construct arrays of filtered messages and convert into json
|
|
|
|
- echo the resulted json
|
|
|
|
- profit |
|
|
|
\ No newline at end of file |