Remote Backends
This commit is contained in:
1 parent
97247e3e29
commit
2ed86e0118
20 files changed
+338
-111
No files matched your search
@@ -10,6 +10,7 @@ function newWorkspace () {
|
||||
container: undefined,
|
||||
enabled: false,
|
||||
nodeChildren: undefined,
|
||||
eventsServerClients: new Map(),
|
||||
save: saveWorkspace,
|
||||
getHierarchyHeads: getHierarchyHeads,
|
||||
getNodeThatIsOnFocus: getNodeThatIsOnFocus,
|
||||
@@ -93,6 +94,7 @@ function newWorkspace () {
|
||||
thisObject.workspaceNode = JSON.parse(savedWorkspace)
|
||||
}
|
||||
functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode)
|
||||
setupEventsServerClients()
|
||||
thisObject.enabled = true
|
||||
|
||||
setInterval(saveWorkspace, 60000)
|
||||
@@ -101,6 +103,38 @@ function newWorkspace () {
|
||||
}
|
||||
}
|
||||
|
||||
function setupEventsServerClients () {
|
||||
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
|
||||
let rootNode = thisObject.workspaceNode.rootNodes[i]
|
||||
|
||||
if (rootNode.type === 'Network') {
|
||||
for (let j = 0; j < rootNode.networkNodes.length; j++) {
|
||||
let networkNode = rootNode.networkNodes[j]
|
||||
|
||||
let host
|
||||
let webSocketsPort
|
||||
/* At this point the node does not have the payload property yet, that is why we have to do this manually */
|
||||
try {
|
||||
let code = JSON.parse(networkNode.code)
|
||||
host = code.host
|
||||
webSocketsPort = code.webSocketsPort
|
||||
} catch (err) {
|
||||
console.log('[ERROR] networkNode ' + networkNode.name + ' has an invalid configuration. Cannot know the host name and webSocketsPort.')
|
||||
return
|
||||
}
|
||||
|
||||
if (host === undefined) { host = 'localhost' }
|
||||
if (webSocketsPort === undefined) { webSocketsPort = '8080' }
|
||||
|
||||
let eventsServerClient = newEventsServerClient(host, webSocketsPort)
|
||||
eventsServerClient.initialize()
|
||||
|
||||
thisObject.eventsServerClients.set(networkNode.id, eventsServerClient)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function chainDetachNode (node) {
|
||||
functionLibraryChainAttachDetach.chainDetachNode(node, thisObject.workspaceNode.rootNodes)
|
||||
}
|
||||
@@ -130,6 +164,19 @@ function newWorkspace () {
|
||||
}
|
||||
|
||||
function physics () {
|
||||
eventsServerClientsPhysics()
|
||||
replacingWorkspacePhysics()
|
||||
}
|
||||
|
||||
function eventsServerClientsPhysics () {
|
||||
thisObject.eventsServerClients.forEach(applyPhysics)
|
||||
|
||||
function applyPhysics (eventServerClient) {
|
||||
eventServerClient.physics()
|
||||
}
|
||||
}
|
||||
|
||||
function replacingWorkspacePhysics () {
|
||||
if (thisObject.enabled !== true) { return }
|
||||
|
||||
if (workingAtTask > 0) {
|
||||
@@ -151,6 +198,7 @@ function newWorkspace () {
|
||||
break
|
||||
case 4:
|
||||
functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode, true)
|
||||
setupEventsServerClients()
|
||||
workingAtTask++
|
||||
break
|
||||
case 5:
|
||||
@@ -358,10 +406,15 @@ function newWorkspace () {
|
||||
downloadText(fileName, text)
|
||||
}
|
||||
|
||||
break
|
||||
case 'Debug Task':
|
||||
{
|
||||
functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode, true, callBackFunction)
|
||||
}
|
||||
break
|
||||
case 'Run Task':
|
||||
{
|
||||
functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode, callBackFunction)
|
||||
functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode, false, callBackFunction)
|
||||
}
|
||||
break
|
||||
case 'Stop Task':
|
||||
|
||||
Reference in new issue
Block a user