From b5a2298fb0713d63fc3a345e2d52486797cbda15 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 8 Nov 2021 13:13:18 +0100 Subject: [PATCH] Enabling multiple desktop apps to run at the same machine - Part 1 --- .vscode/Desktop-App-1.code-workspace | 10 + .vscode/Desktop-App-2.code-workspace | 10 + .vscode/Desktop-App-3.code-workspace | 10 + DesktopRoot.js | 6 +- .../User-Profiles/Luis-Fernando-Molina.json | 202 ++++++++++++++---- .../social-trading-desktop-app.json | 2 +- .../App-Schema/social-trading-mobile-app.json | 2 +- .../App-Schema/social-trading-server-app.json | 2 +- .../SA/Modules/WebSocketsNetworkClient.js | 2 +- desktop-app-1.js | 8 + desktop-app-2.js | 8 + desktop-app-3.js | 8 + network-node-1.js | 12 +- network-node-2.js | 12 +- network-node-3.js | 12 +- 15 files changed, 226 insertions(+), 80 deletions(-) create mode 100644 .vscode/Desktop-App-1.code-workspace create mode 100644 .vscode/Desktop-App-2.code-workspace create mode 100644 .vscode/Desktop-App-3.code-workspace create mode 100644 desktop-app-1.js create mode 100644 desktop-app-2.js create mode 100644 desktop-app-3.js diff --git a/.vscode/Desktop-App-1.code-workspace b/.vscode/Desktop-App-1.code-workspace new file mode 100644 index 000000000..97e2d4c8f --- /dev/null +++ b/.vscode/Desktop-App-1.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "C:\\Superalgos" + } + ], + "settings": { + "search.maintainFileSearchCache": true + } +} \ No newline at end of file diff --git a/.vscode/Desktop-App-2.code-workspace b/.vscode/Desktop-App-2.code-workspace new file mode 100644 index 000000000..97e2d4c8f --- /dev/null +++ b/.vscode/Desktop-App-2.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "C:\\Superalgos" + } + ], + "settings": { + "search.maintainFileSearchCache": true + } +} \ No newline at end of file diff --git a/.vscode/Desktop-App-3.code-workspace b/.vscode/Desktop-App-3.code-workspace new file mode 100644 index 000000000..97e2d4c8f --- /dev/null +++ b/.vscode/Desktop-App-3.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "C:\\Superalgos" + } + ], + "settings": { + "search.maintainFileSearchCache": true + } +} \ No newline at end of file diff --git a/DesktopRoot.js b/DesktopRoot.js index ee7267baf..5a95acdf1 100644 --- a/DesktopRoot.js +++ b/DesktopRoot.js @@ -10,7 +10,7 @@ exports.newDesktopRoot = function newDesktopRoot() { return thisObject - async function run() { + async function run(debugSettings) { /* The DK object is accessible everywhere at the Superalgos Desktop App. It provides access to all modules built for this App. @@ -25,6 +25,10 @@ exports.newDesktopRoot = function newDesktopRoot() { let ENVIRONMENT = require('./Environment.js'); let ENVIRONMENT_MODULE = ENVIRONMENT.newEnvironment() global.env = ENVIRONMENT_MODULE + + if (debugSettings !== undefined && debugSettings.DESKTOP_APP_SIGNING_ACCOUNT !== undefined) { + global.env.DESKTOP_APP_SIGNING_ACCOUNT = debugSettings.DESKTOP_APP_SIGNING_ACCOUNT + } /* First thing is to load the project schema file. */ diff --git a/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json b/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json index 8b9800284..56fa6244d 100644 --- a/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json +++ b/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json @@ -17012,17 +17012,17 @@ "signingAccountChild": { "type": "Social Trading Desktop App", "name": "Social Trading Desktop App # 1", - "config": "{\n \"codeName\": \"Social-Trading-Desktop-App-1\"\n}", + "config": "{\n \"codeName\": \"Social-Trading-Desktop-App-1\",\n \"host\": \"localhost\",\n \"webSocketsPort\": \"17042\"\n}", "project": "Governance", "id": "012c74dd-1a61-4784-bc8a-e18555b4974e", "savedPayload": { "position": { - "x": 32588.466416509047, - "y": 18618.508094196695 + "x": 32596.44477289305, + "y": 18664.939393355322 }, "targetPosition": { - "x": 32885.89987492119, - "y": 18579.35023653068 + "x": 32889.88905311319, + "y": 18602.565886109995 }, "floatingObject": { "isPinned": false, @@ -17040,8 +17040,8 @@ "id": "3863ebb9-c69f-40b2-8bbd-eb8f2b60a49c", "savedPayload": { "position": { - "x": 32885.89987492119, - "y": 18579.35023653068 + "x": 32889.88905311319, + "y": 18602.565886109995 }, "targetPosition": { "x": 33183.333333333336, @@ -17068,17 +17068,17 @@ "signingAccountChild": { "type": "Social Trading Mobile App", "name": "Social Trading Mobile App # 1", - "config": "{\n \"codeName\": \"Social-Trading-Mobile-App-1\"\n}", + "config": "{\n \"codeName\": \"Social-Trading-Mobile-App-1\",\n \"host\": \"localhost\",\n \"webSocketsPort\": \"15042\"\n}", "project": "Governance", "id": "2d03d11f-b553-4b01-9291-9e13da15dd54", "savedPayload": { "position": { - "x": 32603.777837559894, - "y": 18384.900951803153 + "x": 32586.62019611237, + "y": 18477.475300904072 }, "targetPosition": { - "x": 32893.555585446615, - "y": 18462.54666533391 + "x": 32884.97676472285, + "y": 18508.83383988437 }, "floatingObject": { "isPinned": false, @@ -17096,8 +17096,8 @@ "id": "c84e9e64-7527-4dec-ac58-93696e19a756", "savedPayload": { "position": { - "x": 32893.555585446615, - "y": 18462.54666533391 + "x": 32884.97676472285, + "y": 18508.83383988437 }, "targetPosition": { "x": 33183.333333333336, @@ -17124,17 +17124,17 @@ "signingAccountChild": { "type": "Social Trading Server App", "name": "Social Trading Server App # 1", - "config": "{\n \"codeName\": \"Social-Trading-Server-App-1\"\n}", + "config": "{\n \"codeName\": \"Social-Trading-Server-App-1\",\n \"host\": \"localhost\",\n \"webSocketsPort\": \"16042\"\n}", "project": "Governance", "id": "c3d218ee-119f-4bd9-9349-8a194844ecd9", "savedPayload": { "position": { - "x": 32707.321329158593, - "y": 18174.935521459432 + "x": 32635.20605874777, + "y": 18296.15039301919 }, "targetPosition": { - "x": 32945.327331245964, - "y": 18357.56395016205 + "x": 32909.26969604055, + "y": 18418.17138594193 }, "floatingObject": { "isPinned": false, @@ -17152,8 +17152,8 @@ "id": "75f17a55-bf33-4e69-b842-b424a6f517e8", "savedPayload": { "position": { - "x": 32945.327331245964, - "y": 18357.56395016205 + "x": 32909.26969604055, + "y": 18418.17138594193 }, "targetPosition": { "x": 33183.333333333336, @@ -17185,12 +17185,12 @@ "id": "bcffb701-754d-4685-ad09-8bf3f09265d9", "savedPayload": { "position": { - "x": 32883.333333333336, - "y": 18020.577136594 + "x": 32737.446438046896, + "y": 18138.71401504935 }, "targetPosition": { - "x": 33033.333333333336, - "y": 18280.384757729335 + "x": 32960.389885690114, + "y": 18339.45319695701 }, "floatingObject": { "isPinned": false, @@ -17208,8 +17208,8 @@ "id": "377ee3ed-49e4-415d-87b3-946024f0a1ef", "savedPayload": { "position": { - "x": 33033.333333333336, - "y": 18280.384757729335 + "x": 32960.389885690114, + "y": 18339.45319695701 }, "targetPosition": { "x": 33183.333333333336, @@ -17241,12 +17241,12 @@ "id": "bb0f0417-9dfb-47a3-941f-dcfa82fbaea1", "savedPayload": { "position": { - "x": 33105.0176180013, - "y": 17945.325462040382 + "x": 32883.333333333336, + "y": 18020.577136594 }, "targetPosition": { - "x": 33144.17547566732, - "y": 18242.758920452525 + "x": 33033.333333333336, + "y": 18280.384757729335 }, "floatingObject": { "isPinned": false, @@ -17264,8 +17264,8 @@ "id": "7c5f14f9-63c2-42fa-98ee-1d4a36590cf4", "savedPayload": { "position": { - "x": 33144.17547566732, - "y": 18242.758920452525 + "x": 33033.333333333336, + "y": 18280.384757729335 }, "targetPosition": { "x": 33183.333333333336, @@ -17297,12 +17297,12 @@ "id": "76fa8a24-9ab4-4eaf-82f2-458ba557b204", "savedPayload": { "position": { - "x": 33338.62476039485, - "y": 17960.636883091225 + "x": 33058.58631884268, + "y": 17953.303818424385 }, "targetPosition": { - "x": 33260.97904686409, - "y": 18250.414630977946 + "x": 33120.95982608801, + "y": 18246.748098644526 }, "floatingObject": { "isPinned": false, @@ -17320,8 +17320,8 @@ "id": "48544424-5b62-417b-897d-9164b26fcd56", "savedPayload": { "position": { - "x": 33260.97904686409, - "y": 18250.414630977946 + "x": 33120.95982608801, + "y": 18246.748098644526 }, "targetPosition": { "x": 33183.333333333336, @@ -17353,12 +17353,12 @@ "id": "297e57c2-3c1a-4170-b710-d2705804205b", "savedPayload": { "position": { - "x": 33548.59019073856, - "y": 18064.180374689924 + "x": 33246.05041129393, + "y": 17943.479241643705 }, "targetPosition": { - "x": 33365.96176203595, - "y": 18302.186376777296 + "x": 33214.69187231363, + "y": 18241.835810254186 }, "floatingObject": { "isPinned": false, @@ -17376,8 +17376,120 @@ "id": "b39e1c4d-4170-4134-ae85-fc9fa7f3eb47", "savedPayload": { "position": { - "x": 33365.96176203595, - "y": 18302.186376777296 + "x": 33214.69187231363, + "y": 18241.835810254186 + }, + "targetPosition": { + "x": 33183.333333333336, + "y": 18540.192378864667 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 2, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + { + "type": "Signing Account", + "name": "New Signing Account", + "config": "{\n \"signature\": {\n \"message\": \"Luis-Fernando-Molina\",\n \"messageHash\": \"0x443abf3389e332a62d21b84dd12e271cb428d334195d3aeb986ca85ee53cccb9\",\n \"v\": \"0x1b\",\n \"r\": \"0xa21640401c1e1ab44678fd6024654d6200025d75998a38d06a2dbb84d2b965b4\",\n \"s\": \"0x7c1308809675605bf120654214f7566a833158cc54471e8eefbee64e8031a5ce\",\n \"signature\": \"0xa21640401c1e1ab44678fd6024654d6200025d75998a38d06a2dbb84d2b965b47c1308809675605bf120654214f7566a833158cc54471e8eefbee64e8031a5ce1b\"\n }\n}", + "project": "Governance", + "signingAccountChild": { + "type": "Social Trading Desktop App", + "name": "Social Trading Desktop App # 2", + "config": "{\n \"codeName\": \"Social-Trading-Desktop-App-2\",\n \"host\": \"localhost\",\n \"webSocketsPort\": \"17042\"\n}", + "project": "Governance", + "id": "e6f2b6f6-5e40-42d2-92d8-fdd17680a1c7", + "savedPayload": { + "position": { + "x": 33427.37531917882, + "y": 17992.065104279107 + }, + "targetPosition": { + "x": 33305.35432625608, + "y": 18266.128741571887 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 2, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "id": "530b3376-a820-4710-a7a0-bab877e4c4be", + "savedPayload": { + "position": { + "x": 33305.35432625608, + "y": 18266.128741571887 + }, + "targetPosition": { + "x": 33183.333333333336, + "y": 18540.192378864667 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 2, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + { + "type": "Signing Account", + "name": "New Signing Account", + "config": "{\n \"signature\": {\n \"message\": \"Luis-Fernando-Molina\",\n \"messageHash\": \"0x443abf3389e332a62d21b84dd12e271cb428d334195d3aeb986ca85ee53cccb9\",\n \"v\": \"0x1c\",\n \"r\": \"0x4e4870f2f0061fa5a6e5fca672f1543420e140944a65a294ea25f1c2ef1c5dbe\",\n \"s\": \"0x58ba993a911c9092967b51da47be22ad85062d5ce49c6b2de4f6a593c67850c6\",\n \"signature\": \"0x4e4870f2f0061fa5a6e5fca672f1543420e140944a65a294ea25f1c2ef1c5dbe58ba993a911c9092967b51da47be22ad85062d5ce49c6b2de4f6a593c67850c61c\"\n }\n}", + "project": "Governance", + "signingAccountChild": { + "type": "Social Trading Desktop App", + "name": "Social Trading Desktop App # 3", + "config": "{\n \"codeName\": \"Social-Trading-Desktop-App-3\",\n \"host\": \"localhost\",\n \"webSocketsPort\": \"17042\"\n}", + "project": "Governance", + "id": "00ca860e-bb19-42b4-8bce-b67f9a1f9af7", + "savedPayload": { + "position": { + "x": 33584.81169714865, + "y": 18094.30548357823 + }, + "targetPosition": { + "x": 33384.072515240994, + "y": 18317.24893122145 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 2, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "id": "72de2a17-d6f1-491b-847b-4e110a122cf6", + "savedPayload": { + "position": { + "x": 33384.072515240994, + "y": 18317.24893122145 }, "targetPosition": { "x": 33183.333333333336, diff --git a/Projects/Governance/Schemas/App-Schema/social-trading-desktop-app.json b/Projects/Governance/Schemas/App-Schema/social-trading-desktop-app.json index d984011d3..84e3da5ca 100644 --- a/Projects/Governance/Schemas/App-Schema/social-trading-desktop-app.json +++ b/Projects/Governance/Schemas/App-Schema/social-trading-desktop-app.json @@ -25,7 +25,7 @@ "config": true }, "initialValues": { - "config": "{}" + "config": "{ \n\"codeName\": \"localhost\", \n\"host\": \"localhost\", \n\"webSocketsPort\": \"17042\"\n}" }, "addLeftIcons": true, "level": 1, diff --git a/Projects/Governance/Schemas/App-Schema/social-trading-mobile-app.json b/Projects/Governance/Schemas/App-Schema/social-trading-mobile-app.json index 7fa33665c..97202f837 100644 --- a/Projects/Governance/Schemas/App-Schema/social-trading-mobile-app.json +++ b/Projects/Governance/Schemas/App-Schema/social-trading-mobile-app.json @@ -25,7 +25,7 @@ "config": true }, "initialValues": { - "config": "{}" + "config": "{ \n\"codeName\": \"localhost\", \n\"host\": \"localhost\", \n\"webSocketsPort\": \"15042\"\n}" }, "addLeftIcons": true, "level": 1, diff --git a/Projects/Governance/Schemas/App-Schema/social-trading-server-app.json b/Projects/Governance/Schemas/App-Schema/social-trading-server-app.json index 5e15298e5..45d284b28 100644 --- a/Projects/Governance/Schemas/App-Schema/social-trading-server-app.json +++ b/Projects/Governance/Schemas/App-Schema/social-trading-server-app.json @@ -25,7 +25,7 @@ "config": true }, "initialValues": { - "config": "{}" + "config": "{ \n\"codeName\": \"localhost\", \n\"host\": \"localhost\", \n\"webSocketsPort\": \"16042\"\n}" }, "addLeftIcons": true, "level": 1, diff --git a/Projects/Network/SA/Modules/WebSocketsNetworkClient.js b/Projects/Network/SA/Modules/WebSocketsNetworkClient.js index 1542e743f..477553b02 100644 --- a/Projects/Network/SA/Modules/WebSocketsNetworkClient.js +++ b/Projects/Network/SA/Modules/WebSocketsNetworkClient.js @@ -55,7 +55,7 @@ exports.newNetworkModulesWebSocketsNetworkClient = function newNetworkModulesWeb thisObject.socket = new SA.nodeModules.ws('ws://' + thisObject.host + ':' + thisObject.port) await setUpWebSocketClient() - console.log('Websockets Client Connected to Network Node via Web Sockets ................ Connected to ' + thisObject.p2pNetworkNode.userProfile.userProfileHandle + ' -> ' + thisObject.p2pNetworkNode.node.name + ' -> ' + thisObject.host + ':' + thisObject.port) + console.log('Websockets Client Connected to Network Node via Web Sockets .................. Connected to ' + thisObject.p2pNetworkNode.userProfile.userProfileHandle + ' -> ' + thisObject.p2pNetworkNode.node.name + ' -> ' + thisObject.host + ':' + thisObject.port) thisObject.isConnected = true } diff --git a/desktop-app-1.js b/desktop-app-1.js new file mode 100644 index 000000000..fb4dd79c1 --- /dev/null +++ b/desktop-app-1.js @@ -0,0 +1,8 @@ +/* +This is to start a new instance of a test desktop app running with identity #1 as +defined at the Environment.js file. +*/ + +let APP_ROOT = require('./DesktopRoot.js') +let APP_ROOT_MODULE = APP_ROOT.newDesktopRoot() +APP_ROOT_MODULE.run({DESKTOP_APP_SIGNING_ACCOUNT: 'Social-Trading-Desktop-App-1'}) \ No newline at end of file diff --git a/desktop-app-2.js b/desktop-app-2.js new file mode 100644 index 000000000..85e705d77 --- /dev/null +++ b/desktop-app-2.js @@ -0,0 +1,8 @@ +/* +This is to start a new instance of a test desktop app running with identity #2 as +defined at the Environment.js file. +*/ + +let APP_ROOT = require('./DesktopRoot.js') +let APP_ROOT_MODULE = APP_ROOT.newDesktopRoot() +APP_ROOT_MODULE.run({DESKTOP_APP_SIGNING_ACCOUNT: 'Social-Trading-Desktop-App-2'}) \ No newline at end of file diff --git a/desktop-app-3.js b/desktop-app-3.js new file mode 100644 index 000000000..215b8a445 --- /dev/null +++ b/desktop-app-3.js @@ -0,0 +1,8 @@ +/* +This is to start a new instance of a test desktop app running with identity #3 as +defined at the Environment.js file. +*/ + +let APP_ROOT = require('./DesktopRoot.js') +let APP_ROOT_MODULE = APP_ROOT.newDesktopRoot() +APP_ROOT_MODULE.run({DESKTOP_APP_SIGNING_ACCOUNT: 'Social-Trading-Desktop-App-3'}) \ No newline at end of file diff --git a/network-node-1.js b/network-node-1.js index ffb2ccd1e..1e58b469f 100644 --- a/network-node-1.js +++ b/network-node-1.js @@ -1,14 +1,6 @@ /* -The Superalgos Network offers 3 types of services: - - * Social Graph Service - * Search Index Service - * Private Message Service - -Users can decide which services to run at their node.(TODO) - -This module represents the Nodejs command that users have to start the Network Node.. - +This is to start a new instance of a test node running with Node identity #1 as +defined at the Environment.js file. */ let APP_ROOT = require('./NetworkRoot.js') diff --git a/network-node-2.js b/network-node-2.js index 0f36a5e2d..5d28e627c 100644 --- a/network-node-2.js +++ b/network-node-2.js @@ -1,14 +1,6 @@ /* -The Superalgos Network offers 3 types of services: - - * Social Graph Service - * Search Index Service - * Private Message Service - -Users can decide which services to run at their node.(TODO) - -This module represents the Nodejs command that users have to start the Network Node.. - +This is to start a new instance of a test node running with Node identity #2 as +defined at the Environment.js file. */ let APP_ROOT = require('./NetworkRoot.js') diff --git a/network-node-3.js b/network-node-3.js index f8a3ac41e..30d2c5141 100644 --- a/network-node-3.js +++ b/network-node-3.js @@ -1,14 +1,6 @@ /* -The Superalgos Network offers 3 types of services: - - * Social Graph Service - * Search Index Service - * Private Message Service - -Users can decide which services to run at their node.(TODO) - -This module represents the Nodejs command that users have to start the Network Node.. - +This is to start a new instance of a test node running with Node identity #3 as +defined at the Environment.js file. */ let APP_ROOT = require('./NetworkRoot.js')