Profiles Arrived to the Desktop WebApp
This commit is contained in:
1 parent
4125d54016
commit
cdd5cebfc5
4 files changed
+71
-9
No files matched your search
@@ -23,18 +23,18 @@ exports.newDesktopApp = function newDesktopApp() {
|
||||
*/
|
||||
DK.running.webSocketsClient = SA.projects.network.modules.webSocketsClient.newNetworkModulesWebSocketsClient()
|
||||
await DK.running.webSocketsClient.initialize()
|
||||
console.log('Desktop App Client Connected to Network Node via Web Sockets ................... Connected to port ' + global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT)
|
||||
console.log('Desktop Client Connected to Network Node via Web Sockets ................... Connected to port ' + global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT)
|
||||
|
||||
/* These are the Network Interfaces by which the UI interacts with the Desktop App.*/
|
||||
|
||||
DK.running.webSocketsInterface = DK.projects.socialTrading.modules.webSocketsInterface.newDesktopModulesWebSocketsInterface()
|
||||
DK.running.webSocketsInterface.initialize()
|
||||
console.log('Desktop App Client Web Sockets Interface ....................................... Listening at port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT)
|
||||
console.log('Desktop Client 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('Desktop App Client Http Interface .............................................. Listening at port ' + global.env.DESKTOP_HTTP_INTERFACE_PORT)
|
||||
console.log('Desktop Client Http Interface .............................................. Listening at port ' + global.env.DESKTOP_HTTP_INTERFACE_PORT)
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ function newWebApp() {
|
||||
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
async function initialize() {
|
||||
try {
|
||||
setupRootObject(UI, 'UI')
|
||||
setupRootObject(SA, 'SA')
|
||||
UI.projects.socialTrading.modules.webSocketsClient.initialize()
|
||||
await UI.projects.socialTrading.modules.webSocketsClient.initialize()
|
||||
setupHomePage()
|
||||
} catch (err) {
|
||||
console.log('[ERROR] initialize -> err.stack = ' + err.stack)
|
||||
@@ -101,7 +101,7 @@ function newWebApp() {
|
||||
*/
|
||||
queryMessage = {
|
||||
queryType: SA.projects.socialTrading.globals.queryTypes.USER_PROFILES,
|
||||
emitterUserProfileId: undefined, //DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID,
|
||||
emitterUserProfileId: undefined,
|
||||
initialIndex: 'Last',
|
||||
amountRequested: 10,
|
||||
direction: 'Past'
|
||||
|
||||
@@ -20,8 +20,68 @@ exports.newSocialTradingModulesWebAppInterface = function newSocialTradingModule
|
||||
|
||||
}
|
||||
|
||||
async function messageReceived(messageHeader) {
|
||||
let response = await DK.running.webSocketsClient.sendMessage(messageHeader)
|
||||
return response
|
||||
async function messageReceived(message) {
|
||||
let messageHeader
|
||||
try {
|
||||
messageHeader = JSON.parse(message)
|
||||
} catch (err) {
|
||||
let response = {
|
||||
result: 'Error',
|
||||
message: 'messageHeader Not Coorrect JSON Format.'
|
||||
}
|
||||
return JSON.stringify(response)
|
||||
}
|
||||
|
||||
switch (messageHeader.requestType) {
|
||||
case 'Query': {
|
||||
let queryMessage
|
||||
try {
|
||||
queryMessage = JSON.parse(messageHeader.queryMessage)
|
||||
} catch (err) {
|
||||
let response = {
|
||||
result: 'Error',
|
||||
message: 'queryMessage Not Coorrect JSON Format.'
|
||||
}
|
||||
return JSON.stringify(response)
|
||||
}
|
||||
queryMessage.emitterUserProfileId = DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID
|
||||
messageHeader.queryMessage = JSON.stringify(queryMessage)
|
||||
|
||||
let response = {
|
||||
result: 'Ok',
|
||||
message: 'Web App Interface Query Processed.',
|
||||
data: await DK.running.webSocketsClient.sendMessage(JSON.stringify(messageHeader))
|
||||
}
|
||||
return response
|
||||
}
|
||||
case 'Event': {
|
||||
let eventMessage
|
||||
try {
|
||||
eventMessage = JSON.parse(messageHeader.eventMessage)
|
||||
} catch (err) {
|
||||
let response = {
|
||||
result: 'Error',
|
||||
message: 'eventMessage Not Coorrect JSON Format.'
|
||||
}
|
||||
return JSON.stringify(response)
|
||||
}
|
||||
eventMessage.emitterUserProfileId = DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID
|
||||
messageHeader.eventMessage = JSON.stringify(eventMessage)
|
||||
|
||||
let response = {
|
||||
result: 'Ok',
|
||||
message: 'Web App Interface Event Processed.',
|
||||
data: await DK.running.webSocketsClient.sendMessage(JSON.stringify(messageHeader))
|
||||
}
|
||||
return response
|
||||
}
|
||||
default: {
|
||||
let response = {
|
||||
result: 'Error',
|
||||
message: 'requestType Not Supported.'
|
||||
}
|
||||
return JSON.stringify(response)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ exports.newDesktopModulesWebSocketsInterface = function newDesktopModulesWebSock
|
||||
webApp = {
|
||||
socket: socket
|
||||
}
|
||||
console.log('Desktop Web App Connected to Web Sockets Interface ......................... Connected to port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT)
|
||||
|
||||
webApp.socket.on('close', onConnectionClosed)
|
||||
webApp.socket.on('message', onMenssage)
|
||||
@@ -74,6 +75,7 @@ exports.newDesktopModulesWebSocketsInterface = function newDesktopModulesWebSock
|
||||
|
||||
function onConnectionClosed() {
|
||||
webApp = undefined
|
||||
console.log('Desktop Web App Discoonnected from Web Sockets Interface ................... Disonnected from port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT)
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
|
||||
Reference in new issue
Block a user