Skip to content

Commit

Permalink
GPII-4218: Fixed comments, tests, and examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
klown committed Jun 16, 2020
1 parent 608c108 commit d42c459
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 48 deletions.
22 changes: 22 additions & 0 deletions examples/browserChannelClient/browserChannelClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var ws = require("ws");

var socket = new ws("ws://localhost:8081/browserChannel"); // eslint-disable-line new-cap

var changeSetting = false;

// When the connection is done, the client tells to the flow manager its id

socket.on("open", function () {
Expand All @@ -39,11 +41,31 @@ socket.on("message", function (data) {
// Right after sending the id to the flow manager, the server will return back
// the current settings in the system (if any)
if (message.type === "connectionSucceeded") {
changeSetting = true;
console.log("## browserChannelClient: Got initial settings ", message.payload, " on connection");
}
// By listening to this message type, the client will be notified when the system has
// new settings to be applied on the client side
else if (message.type === "onSettingsChanged") {
console.log("## browserChannelClient: Got changed settings ", message.payload);
}
// Log acknowledgement that the "changeSettings" message was sent
else if (message.type === "changeSettingsReceived") {
console.log("## browserChannelClient: ChangeSettings was successfully sent ", message.payload);
}

// Change two settings, and be done.
if (changeSetting) {
changeSetting = false;
socket.send(JSON.stringify({
type: "changeSettings",
payload: {
settings: {
characterSpace: 1,
clickToSelectEnabled: false,
contrastTheme: "default"
}
}
}));
}
});
2 changes: 1 addition & 1 deletion examples/pspChannelClient/pspChannelClientReadPrefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ socket.on("message", function (data) {
"type": "pullModel",
value: {
settingControls: {
"http://registry\\.gpii\\.net/common/DPIScale": {
"http://registry\\.gpii\\.net/common/magnification": {
value: 1
}
}
Expand Down
14 changes: 14 additions & 0 deletions gpii/node_modules/flowManager/src/BrowserChannel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*!
GPII BrowserChannel Handler
Copyright 2014, 2015 Emergya
Copyright 2015-2018 Raising the Floor - International
Copyright 2020 OCAD University
Licensed under the New BSD license. You may not use this file except in
compliance with this License.
You may obtain a copy of the License at
https://github.com/gpii/universal/LICENSE.txt
*/

"use strict";

var fluid = require("infusion");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ gpii.tests.flowManager.browserChannel.testDefs = [{
sequence: [{
func: "gpii.tests.flowManager.browserChannel.checkClients"
}, {
func: "{clientOne}.connect" // chromeClient (org.chrome.cloud4chrome)
func: "{clientOne}.connect" // chromeClient (org.nvda-project)
}, {
event: "{clientOne}.events.onConnect",
listener: "fluid.identity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Copyright 2014, 2015 Emergya
Copyright 2015 Raising the Floor - International
Copyright 2020 IDRC, OCAD University
Copyright 2020 OCAD University
Licensed under the New BSD license. You may not use this file except in
compliance with this License.
Expand Down Expand Up @@ -91,7 +91,7 @@ gpii.settingsHandlers.webSockets.addClient = function (that, solutionId, client)
};

/**
* Remoove a client, a web sockets message handler, from the set of clients that
* Remove a client, a web sockets message handler, from the set of clients that
* this settings handler services.
* @param {Component} that - An instance of gpii.settingsHandlers.webSockets.component.
* @param {Component} client - The client request handler to remove.
Expand Down Expand Up @@ -152,14 +152,13 @@ gpii.settingsHandlers.webSockets.getImpl = function (payload, that) {

/**
* Modify the persistent settings based on the values passed in, and notify
* relevant clients of the changes.
* relevant clients of the changes. In this regard, the client that requested
* the settings is sent an acknowledgement using a "changeSettingsReceived"
* message type. The other clients are sent a "onSettingsChanged" message.
* @param {Object} payload - Information about which settings to modify.
* @param {Object} payload.settings - The new values of the settings.
* @param {String} payload.options.path - Solution id whose setting are to change.
* @param {String} payload.options.path - Solution id whose settings are to change.
* @param {String} payload.options.source - The client requesting the changes.
* This client will not be notified of
* any changes. Other clients, who
* support the same solution, will.
* @param {Component} that - An instance of gpii.settingsHandlers.webSockets.component.
* @param {String} solutionId - The solution whose setting are sought.
* @return {Object} - a set of old value, new value pairs showing the changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,40 +92,6 @@ webSocketsTests.payloads = {
}
]
},
setPayloadNoNotify: {
"net.gpii.test": [
{
settings: {
dog: "woof",
cat: "meow",
amount: 3,
cheese: ["gouda", "brugge"],
"beers.trappiste": "Chimay",
"beers.blanche": "Hoegaarden",
"beers.scotch": "Achouffe McChouffe"
},
options: {
path: "net.gpii.test",
dontNotify: true
}
}
]
},
expectedSetReturnPayloadNoNotify: {
"net.gpii.test": [
{
settings: {
dog: { oldValue: "woof", newValue: "woof" },
cat: { oldValue: "meow" , newValue: "meow" },
amount: { oldValue: 3, newValue: 3 },
cheese: { oldValue: ["gouda", "brugge"], newValue: ["gouda", "brugge"] },
"beers.trappiste": {oldValue: "Chimay", newValue: "Chimay" },
"beers.blanche": {oldValue: "Hoegaarden", newValue: "Hoegaarden" },
"beers.scotch": {oldValue: "Achouffe McChouffe", newValue: "Achouffe McChouffe" }
}
}
]
},
restorePayload: {
"net.gpii.test": [
{
Expand Down Expand Up @@ -183,11 +149,6 @@ jqUnit.test("Checking wsSettingsHandler's get/set methods", function () {
webSocketsTests.payloads.expectedSetReturnPayload,
setReturnPayload);

var setReturnPayloadNoNotify = gpii.resolveSync(gpii.settingsHandlers.webSockets.set(webSocketsTests.payloads.setPayloadNoNotify));
jqUnit.assertDeepEq("Set function returns the expected payload",
webSocketsTests.payloads.expectedSetReturnPayloadNoNotify,
setReturnPayloadNoNotify);

var restoreReturnPayload = gpii.resolveSync(gpii.settingsHandlers.webSockets.set(webSocketsTests.payloads.restorePayload));
jqUnit.assertDeepEq("Restore returns the expected payload",
webSocketsTests.payloads.expectedRestoreReturnPayload,
Expand Down

0 comments on commit d42c459

Please sign in to comment.