Ready to request profiles
This commit is contained in:
1 parent
a9cf324199
commit
303c8a9920
9 files changed
+86
-76
No files matched your search
+17
-11
@@ -8,25 +8,31 @@ exports.newDesktopApp = function newDesktopApp() {
|
||||
|
||||
async function run() {
|
||||
/*
|
||||
let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph()
|
||||
await socialGraphService.initialize()
|
||||
Heree we will store our running objects:
|
||||
*/
|
||||
DK.running = {}
|
||||
|
||||
/*
|
||||
This is the Web Sockets client that interacts with the Superalgos Network.
|
||||
*/
|
||||
DK.webSocketsClient = SA.projects.network.modules.webSocketsClient.newNetworkModulesWebSocketsClient()
|
||||
await DK.webSocketsClient.initialize()
|
||||
DK.running.socialGraph = DK.projects.socialTrading.modules.socialTrading.newSocialTradingModulesSocialGraph()
|
||||
await DK.running.socialGraph.initialize()
|
||||
|
||||
/*
|
||||
This is the Web Sockets client that interacts with the Superalgos Network.
|
||||
*/
|
||||
DK.running.webSocketsClient = SA.projects.network.modules.webSocketsClient.newNetworkModulesWebSocketsClient()
|
||||
await DK.running.webSocketsClient.initialize()
|
||||
|
||||
/* These are the Network Interfaces by which the UI interacts with the Desktop App.*/
|
||||
|
||||
WEB_SOCKETS_INTERFACE = DK.projects.socialTrading.modules.webSocketsInterface.newDesktopModulesWebSocketsInterface()
|
||||
WEB_SOCKETS_INTERFACE.initialize()
|
||||
console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT)
|
||||
|
||||
|
||||
HTTP_INTERFACE = DK.projects.socialTrading.modules.httpInterface.newDesktopModulesHttpInterface()
|
||||
HTTP_INTERFACE.initialize()
|
||||
DK.running.webSocketsInterface = DK.projects.socialTrading.modules.webSocketsInterface.newDesktopModulesWebSocketsInterface()
|
||||
DK.running.webSocketsInterface.initialize()
|
||||
console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT)
|
||||
|
||||
|
||||
DK.running.httpInterface = DK.projects.socialTrading.modules.httpInterface.newDesktopModulesHttpInterface()
|
||||
DK.running.httpInterface.initialize()
|
||||
console.log('Http Interface .............................................. Listening at port ' + global.env.DESKTOP_HTTP_INTERFACE_PORT)
|
||||
|
||||
return
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
let webApp
|
||||
let PROJECTS_SCHEMA
|
||||
let ENVIRONMENT
|
||||
|
||||
/* New Root object*/
|
||||
let UI = {
|
||||
|
||||
+5
-50
@@ -14,7 +14,8 @@ function newWebApp() {
|
||||
function initialize() {
|
||||
try {
|
||||
setupRootObject()
|
||||
//setupHomePage()
|
||||
UI.projects.socialTrading.modules.webSocketsClient.initialize()
|
||||
setupHomePage()
|
||||
} catch (err) {
|
||||
console.log('[ERROR] initialize -> err.stack = ' + err.stack)
|
||||
}
|
||||
@@ -85,7 +86,7 @@ function newWebApp() {
|
||||
queryMessage: JSON.stringify(queryMessage)
|
||||
}
|
||||
|
||||
await DK.webSocketsClient.sendMessage(
|
||||
await UI.projects.socialTrading.modules.webSocketsClient.sendMessage(
|
||||
JSON.stringify(query)
|
||||
)
|
||||
.then(showProfiles)
|
||||
@@ -97,56 +98,10 @@ function newWebApp() {
|
||||
for (let i = 0; i < profiles.length; i++) {
|
||||
let profile = profiles[i]
|
||||
|
||||
/*
|
||||
Test Following Profiles.
|
||||
*/
|
||||
let eventMessage = {
|
||||
eventId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(),
|
||||
eventType: SA.projects.socialTrading.globals.eventTypes.FOLLOW_USER_PROFILE,
|
||||
emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID,
|
||||
targetUserProfileId: profile.userProfileId
|
||||
}
|
||||
|
||||
let event = {
|
||||
requestType: 'Event',
|
||||
eventMessage: JSON.stringify(eventMessage)
|
||||
}
|
||||
|
||||
await DK.webSocketsClient.sendMessage(
|
||||
JSON.stringify(event)
|
||||
)
|
||||
.then(followAdded)
|
||||
.catch(onError)
|
||||
|
||||
function followAdded() {
|
||||
console.log("User Profile " + profile.userProfileHandle + " followed.")
|
||||
}
|
||||
console.log(profile)
|
||||
}
|
||||
}
|
||||
/*
|
||||
Test Query User Profile Stats.
|
||||
*/
|
||||
queryMessage = {
|
||||
queryType: SA.projects.socialTrading.globals.queryTypes.USER_PROFILE_STATS,
|
||||
emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID,
|
||||
targetUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID
|
||||
}
|
||||
|
||||
query = {
|
||||
requestType: 'Query',
|
||||
queryMessage: JSON.stringify(queryMessage)
|
||||
}
|
||||
|
||||
await DK.webSocketsClient.sendMessage(
|
||||
JSON.stringify(query)
|
||||
)
|
||||
.then(showProfilesStats)
|
||||
.catch(onError)
|
||||
|
||||
function showProfilesStats(profile) {
|
||||
console.log(profile)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Error Handling
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,16 @@ function newWebAppPostLoader() {
|
||||
function start() {
|
||||
try {
|
||||
|
||||
setupProjectsSchema()
|
||||
setupEnvironment()
|
||||
|
||||
function setupEnvironment() {
|
||||
httpRequest(undefined, 'Environment', onResponse)
|
||||
|
||||
function onResponse(err, file) {
|
||||
ENVIRONMENT = JSON.parse(file)
|
||||
setupProjectsSchema()
|
||||
}
|
||||
}
|
||||
|
||||
function setupProjectsSchema() {
|
||||
httpRequest(undefined, 'ProjectsSchema', onResponse)
|
||||
|
||||
@@ -1492,6 +1492,12 @@
|
||||
"propertyName": "webAppInterface",
|
||||
"functionName": "newSocialTradingModulesWebAppInterface",
|
||||
"fileName": "WebAppInterface.js"
|
||||
},
|
||||
{
|
||||
"name": "Social Graph",
|
||||
"propertyName": "socialGraph",
|
||||
"functionName": "newSocialTradingModulesSocialGraph",
|
||||
"fileName": "SocialGraph.js"
|
||||
}
|
||||
],
|
||||
"utilities": []
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
exports.newSocialTradingModulesSocialGraph = function newSocialTradingModulesSocialGraph() {
|
||||
/*
|
||||
This module mantains in memory the personal social graph for
|
||||
the user profile of the user of the Desktop App. A personal social
|
||||
graph is very similar to the one mantained at a Netwrok Node,
|
||||
the mainn difference is that it only includes information relevant
|
||||
to this particular user, and not for al the users in the system
|
||||
as in the Network Node.
|
||||
*/
|
||||
let thisObject = {
|
||||
messageReceived: messageReceived,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
exports.newSocialTradingModulesWebAppInterface = function newSocialTradingModulesWebAppInterface() {
|
||||
|
||||
/*
|
||||
This module handles the incomming messages from the Web App.
|
||||
At it's current iteration, it will jusr forward those messages
|
||||
to the Network Node it is connected to.
|
||||
*/
|
||||
let thisObject = {
|
||||
sendToWebApp: undefined,
|
||||
messageReceived: messageReceived,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
@@ -17,11 +20,8 @@ exports.newSocialTradingModulesWebAppInterface = function newSocialTradingModule
|
||||
|
||||
}
|
||||
|
||||
function messageReceived(messageHeader) {
|
||||
let response = {
|
||||
result: 'Ok',
|
||||
message: 'Hello !'
|
||||
}
|
||||
return
|
||||
async function messageReceived(messageHeader) {
|
||||
let response = await DK.running.webSocketsClient.sendMessage(messageHeader)
|
||||
return response
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
exports.newDesktopModulesWebSocketsInterface = function newDesktopModulesWebSocketsInterface() {
|
||||
|
||||
/*
|
||||
This module handles the websockets communication between the
|
||||
Desktop App's Client and the Destop App's Web App.
|
||||
*/
|
||||
let thisObject = {
|
||||
sendToWebApp: sendToWebApp,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
@@ -27,7 +31,6 @@ exports.newDesktopModulesWebSocketsInterface = function newDesktopModulesWebSock
|
||||
function setUpWebSocketServer() {
|
||||
try {
|
||||
socketServer.on('connection', onConnectionOpened)
|
||||
webAppInterface.sendToWebApp = sendToWebApp
|
||||
|
||||
function onConnectionOpened(socket)
|
||||
|
||||
@@ -73,12 +76,12 @@ exports.newDesktopModulesWebSocketsInterface = function newDesktopModulesWebSock
|
||||
webApp = undefined
|
||||
}
|
||||
|
||||
function sendToWebApp(message) {
|
||||
webApp.socket.send(JSON.stringify(message))
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log('[ERROR] Web Sockets Interface -> setUpWebSocketServer -> err.stack = ' + err.stack)
|
||||
}
|
||||
|
||||
function sendToWebApp(message) {
|
||||
webApp.socket.send(JSON.stringify(message))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,11 @@ exports.newDesktopModulesHttpInterface = function newDesktopModulesHttpInterface
|
||||
let endpointOrFile = requestPath[1]
|
||||
|
||||
switch (endpointOrFile) {
|
||||
case 'Environment':
|
||||
{
|
||||
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(global.env), httpResponse)
|
||||
}
|
||||
break
|
||||
case 'ProjectsSchema':
|
||||
{
|
||||
let path = global.env.PATH_TO_PROJECTS + '/' + 'ProjectsSchema.json'
|
||||
|
||||
Reference in new issue
Block a user