gpii-universal
Version:
Cross platform, core components of the GPII personalization infrastructure.
163 lines (129 loc) • 4.68 kB
Markdown
This directory contains a tiny sample client for the pspChannel WebSockets connection.
It can be tested by firing up any configuration of the GPII which includes a local FlowManager. Particularly
suitable are the mock configurations in %gpii-universal/gpii/configs/mocks - for example you can run
`node gpii.js gpii/configs/mocks gpii.config.development.manualTesting.mock.windows`
or
`node gpii.js gpii/configs/mocks gpii.config.untrusted.development.manualTesting.mock.windows`
from the root of this repository. This will start up the servers in trusted or untrusted mode, respectively.
After that, you can fire up the client at any time during the lifetime of the FlowManager by typing
`node pspChannelClient.js`
from this directory in another shell.
Before or after that, you can experiment with logging in and out of the GPII using endpoints such as
`http://localhost:8081/user/snapset_1a/login`
and
`http://localhost:8081/user/snapset_1a/logout`
Note that the preference sets used with the above configurations should be in the testData/preferences folder of this
repository.
Here are some sample payloads collected from this client during such testing.
Firstly, connecting the client when no user is keyed into the system produces the payload
```json
{
"type": "modelChanged",
"payload": {
"path": [],
"type": "ADD",
"value": {
"gpiiKey": "noUser",
"activePrefsSetName": "gpii-default",
"settingControls": {},
"preferences": {}
}
}
}
```
After logging in `snapset_1a`, the client receives the following update:
```json
{
"type": "modelChanged",
"payload": {
"path": [],
"type": "ADD",
"value": {
"gpiiKey": "snapset_1a",
"activePrefsSetName": "gpii-default",
"settingControls": {
"http://registry\\.gpii\\.net/common/DPIScale": {
"value": 1.25,
"schema": {
"title": "DPI Scale",
"description": "DPI scale factor on default monitor",
"type": "number",
"min": 1,
"max": 2,
"divisibleBy": 0.25
}
},
"http://registry\\.gpii\\.net/common/cursorSize": {
"value": 1,
"schema": {
"title": "Cursor Size",
"description": "Cursor size",
"type": "number",
"min": 0,
"max": 1,
"divisibleBy": 0.1
}
}
},
"preferences": {
"name": "Larger 125%",
"contexts": {
"gpii-default": {
"name": "Default preferences"
}
}
}
}
}
}
```
After logging out `snapset_1a`, the client receives the following update:
```json
{
"type": "modelChanged",
"payload": {
"path": [],
"value": null,
"type": "DELETE"
}
}
```
When the PSP issues an update to the preferences (see below), a message will be sent to the PSP once the settings change
has been applied to the system:
```json
{
"type": "preferencesApplied"
}
```
The PSP has can send two different payloads to the GPII core architecture. Namely a change in the set of preferences
to use or a change in a setting.
Changing the preferences set via the psp is done with the following payload:
```json
{
"type": "modelChanged",
"value": {
"activePrefsSetName": "bright"
}
}
```
This will change the preferences set to that named by the key "bright". To change the set to something else, simply
exchange "bright" with the name of the desired preferences set.
The PSP API also supports changing preferences (one at a time). This is done via the following payload:
```json
{
"type": "modelChanged",
"value": {
"settingControls": {
"http://registry\\.gpii\\.net/common/magnification": {
"value": 4
}
}
}
}
```
Where the value for the "preferences" key is the setting that should change, and the value for the "value" is the new
value the setting should take. So in the above example the common term magnification is set to 4.