Merge pull request #1647 from Luis-Fernando-Molina/develop

Contribution: Platform Bug Fixed: CLIENT_WEB_SOCKETS_INTERFACE_PORT not correctly refactored.
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-09-03 08:58:52 -04:00
commit 6532fec733
14 files changed
+95 -54

No files matched your search

+39 -9
View File
@@ -17,30 +17,60 @@ exports.newDesktopApp = function newDesktopApp() {
DK.webSocketsClient = SA.projects.network.modules.webSocketsClient.newNetworkModulesWebSocketsClient()
await DK.webSocketsClient.initialize()
let queryMessage = {
equeryId: "123",
queryType: 0,
let queryMessage
let query
/*
Test Query User Profiles.
*/
queryMessage = {
queryType: SA.projects.socialTrading.globals.queryTypes.USER_PROFILES,
emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID,
initialIndex: 'Last',
amountRequested: 10,
direction: 'Past'
}
let query = {
query = {
requestType: 'Query',
queryMessage : JSON.stringify(queryMessage )
queryMessage: JSON.stringify(queryMessage)
}
await DK.webSocketsClient.sendMessage(
JSON.stringify(query)
)
.then(showProfiles)
.catch(onError)
function showProfiles(profiles){
.then(showProfiles)
.catch(onError)
function showProfiles(profiles) {
console.log(profiles)
}
/*
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
*/
function onError(errorMessage) {
console.log('[ERROR] Query not executed. ' + errorMessage)
}
@@ -24,7 +24,7 @@
host = 'localhost'
}
if (port === undefined) {
port = global.env.WEB_SOCKETS_INTERFACE_PORT
port = global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT
}
let messageCounter = 0
+16 -6
View File
@@ -1306,12 +1306,6 @@
"propertyName": "socialTrading",
"NT": {
"globals": [
{
"name": "Query Constants",
"propertyName": "queryConstants",
"functionName": "newSocialTradingGlobalsQueryConstants",
"fileName": "QueryConstants.js"
},
{
"name": "Memory",
"propertyName": "memory",
@@ -1431,6 +1425,22 @@
"fileName": "QueriesValidations.js"
}
]
},
"SA": {
"globals": [
{
"name": "Query Constants",
"propertyName": "queryConstants",
"functionName": "newSocialTradingGlobalsQueryConstants",
"fileName": "QueryConstants.js"
},
{
"name": "Query Types",
"propertyName": "queryTypes",
"functionName": "newSocialTradingGlobalsQueryTypes",
"fileName": "QueryTypes.js"
}
]
}
}
]
@@ -145,7 +145,6 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule
We expect here a JSON string with some or all of the following properties:
{
"equeryId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"queryType": 10,
"emitterUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"targetUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
@@ -29,7 +29,7 @@ exports.newSocialTradingModulesQueriesEvents = function newSocialTradingModulesQ
function execute() {
let response = []
switch (thisObject.direction) {
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let event = NT.memory.arrays.EVENTS[i]
if (event === undefined) { break }
@@ -37,7 +37,7 @@ exports.newSocialTradingModulesQueriesEvents = function newSocialTradingModulesQ
}
break
}
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let event = NT.memory.arrays.EVENTS[i]
if (event === undefined) { break }
@@ -43,7 +43,7 @@ exports.newSocialTradingModulesQueriesPostReplies = function newSocialTradingMod
switch (thisObject.direction) {
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let arrayItem = thisObject.array[i]
if (post === undefined) { break }
@@ -51,7 +51,7 @@ exports.newSocialTradingModulesQueriesPostReplies = function newSocialTradingMod
}
break
}
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let arrayItem = thisObject.array[i]
if (post === undefined) { break }
@@ -35,7 +35,7 @@ exports.newSocialTradingModulesQueriesProfileFollowers = function newSocialTradi
let response = []
switch (thisObject.direction) {
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
@@ -35,7 +35,7 @@ exports.newSocialTradingModulesQueriesProfileFollowing = function newSocialTradi
let response = []
switch (thisObject.direction) {
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
@@ -43,7 +43,7 @@ exports.newSocialTradingModulesQueriesProfileFollowing = function newSocialTradi
}
break
}
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
@@ -38,7 +38,7 @@ exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradi
let response = []
switch (thisObject.direction) {
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
@@ -46,7 +46,7 @@ exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradi
}
break
}
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
@@ -37,7 +37,7 @@ exports.newSocialTradingModulesQueriesUserProfiles = function newSocialTradingMo
let response = []
switch (thisObject.direction) {
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
@@ -45,7 +45,7 @@ exports.newSocialTradingModulesQueriesUserProfiles = function newSocialTradingMo
}
break
}
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
case SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
+8 -21
View File
@@ -15,19 +15,6 @@ exports.newSocialTradingModulesQuery = function newSocialTradingModulesQuery() {
finalize: finalize
}
const QUERY_TYPES = {
USER_PROFILES: 0,
USER_PROFILE_STATS: 1,
BOT_PROFILE_STATS: 2,
PROFILE_POSTS: 3,
PROFILE_FOLLOWERS: 4,
PROFILE_FOLLOWING: 5,
POST_REPLIES: 6,
EVENTS: 7
}
return thisObject
function finalize() {
@@ -41,49 +28,49 @@ exports.newSocialTradingModulesQuery = function newSocialTradingModulesQuery() {
switch (thisObject.queryType) {
case QUERY_TYPES.USER_PROFILES: {
case SA.projects.socialTrading.globals.queryTypes.USER_PROFILES: {
thisObject.query = NT.projects.socialTrading.modules.queriesUserProfiles.newSocialTradingModulesQueriesUserProfiles()
thisObject.query.initialize(queryReceived)
break
}
case QUERY_TYPES.USER_PROFILE_STATS: {
case SA.projects.socialTrading.globals.queryTypes.USER_PROFILE_STATS: {
thisObject.query = NT.projects.socialTrading.modules.queriesUserProfileStats.newSocialTradingModulesQueriesUserProfileStats()
thisObject.query.initialize(queryReceived)
break
}
case QUERY_TYPES.BOT_PROFILE_STATS: {
case SA.projects.socialTrading.globals.queryTypes.BOT_PROFILE_STATS: {
thisObject.query = NT.projects.socialTrading.modules.queriesBotProfileStats.newSocialTradingModulesQueriesBotProfileStats()
thisObject.query.initialize(queryReceived)
break
}
case QUERY_TYPES.PROFILE_POSTS: {
case SA.projects.socialTrading.globals.queryTypes.PROFILE_POSTS: {
thisObject.query = NT.projects.socialTrading.modules.queriesProfilePosts.newSocialTradingModulesQueriesProfilePosts()
thisObject.query.initialize(queryReceived)
break
}
case QUERY_TYPES.POST_REPLIES: {
case SA.projects.socialTrading.globals.queryTypes.POST_REPLIES: {
thisObject.query = NT.projects.socialTrading.modules.queriesPostReplies.newSocialTradingModulesQueriesPostReplies()
thisObject.query.initialize(queryReceived)
break
}
case QUERY_TYPES.PROFILE_FOLLOWERS: {
case SA.projects.socialTrading.globals.queryTypes.PROFILE_FOLLOWERS: {
thisObject.query = NT.projects.socialTrading.modules.queriesProfileFollowers.newSocialTradingModulesQueriesProfileFollowers()
thisObject.query.initialize(queryReceived)
break
}
case QUERY_TYPES.PROFILE_FOLLOWING: {
case SA.projects.socialTrading.globals.queryTypes.PROFILE_FOLLOWING: {
thisObject.query = NT.projects.socialTrading.modules.queriesProfileFollowing.newSocialTradingModulesQueriesProfileFollowing()
thisObject.query.initialize(queryReceived)
break
}
case QUERY_TYPES.maps.EVENTS: {
case SA.projects.socialTrading.globals.queryTypes.maps.EVENTS: {
thisObject.query = NT.projects.socialTrading.modules.queriesEvents.newSocialTradingModulesQueriesEvents()
thisObject.query.initialize(queryReceived)
break
@@ -51,11 +51,11 @@ exports.newSocialTradingUtilitiesQueriesValidations = function newSocialTradingU
throw ('Initial Index Undefined.')
}
if (queryReceived.initialIndex === NT.projects.socialTrading.globals.queryConstants.INITIAL_INDEX_LAST) {
if (queryReceived.initialIndex === SA.projects.socialTrading.globals.queryConstants.INITIAL_INDEX_LAST) {
queryReceived.initialIndex = array.length - 1
}
if (queryReceived.initialIndex === NT.projects.socialTrading.globals.queryConstants.INITIAL_INDEX_FIRST) {
if (queryReceived.initialIndex === SA.projects.socialTrading.globals.queryConstants.INITIAL_INDEX_FIRST) {
queryReceived.initialIndex = 0
}
@@ -75,11 +75,11 @@ exports.newSocialTradingUtilitiesQueriesValidations = function newSocialTradingU
throw ('Amount Requested Is Not a Number.')
}
if (queryReceived.amountRequested < NT.projects.socialTrading.globals.queryConstants.MIN_AMOUNT_REQUESTED) {
if (queryReceived.amountRequested < SA.projects.socialTrading.globals.queryConstants.MIN_AMOUNT_REQUESTED) {
throw ('Amount Requested Below Min.')
}
if (queryReceived.amountRequested > NT.projects.socialTrading.globals.queryConstants.MAX_AMOUNT_REQUESTED) {
if (queryReceived.amountRequested > SA.projects.socialTrading.globals.queryConstants.MAX_AMOUNT_REQUESTED) {
throw ('Amount Requested Above Max.')
}
@@ -91,7 +91,7 @@ exports.newSocialTradingUtilitiesQueriesValidations = function newSocialTradingU
throw ('Direction Undefined.')
}
if (queryReceived.direction !== NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE && queryReceived.direction !== NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST) {
if (queryReceived.direction !== SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE && queryReceived.direction !== SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST) {
throw ('Direction Not Supported.')
}
@@ -0,0 +1,15 @@
exports.newSocialTradingGlobalsQueryTypes = function () {
let thisObject = {
USER_PROFILES: 0,
USER_PROFILE_STATS: 1,
BOT_PROFILE_STATS: 2,
PROFILE_POSTS: 3,
PROFILE_FOLLOWERS: 4,
PROFILE_FOLLOWING: 5,
POST_REPLIES: 6,
EVENTS: 7
}
return thisObject
}