Frontend API

@Injectable() export class SocketService

This service provides a websocket connexion from this frontend to the backend. The websocket is used to connect the user interface to a specific project, selected on the Workspace-chooser view.

The methods to communicate with the backend about workflow changes are implemented in this class.

Only one instance must exists at runtime.

Created by antoine on 15/06/2017.

connect (address: string, workspaceId: string)

Connect the websocket to the given address and subprotocol and set the onopen, onmessage, onerror and onclose methods on the WebSocket instance.

close ()

Close the WebSocket connexion. After the socket is closed, it is impossible to communicate with the server about the project.

async reconnectSocket ()

Reconnect the WebSocket to the already configured address and workspace.

handleClose (ev: CloseEvent)

Handle the CloseEvent from the WebSocket instance.

async handleOpen (ev: Event)

Handle the open event of the WebSocket.

Right after connexion, it request the list of components for the selected workspace and the content of the root directory of the project.

handleMessage (ev: MessageEvent)

Handle the message received on the WebSocket.

handleError (ev: ErrorEvent)

Handle the error event of the WebSocket.

setEventHub (eventHub: any): void

Set the eventhub instance. The eventhub is a GoldenLayout component used as a hub to centralize the communication between the views.

async networkGetStatus ()

Send a network:getstatus message.

https://flowbased.github.io/fbp-protocol/#network-getstatus

sendAddNode (node: Node)

Send a “graph:addnode” message. To use after the user added a node on the graph.

https://flowbased.github.io/fbp-protocol/#graph-addnode

sendRemoveNode (node: Node)

Send a “graph:removenode” message. To use after the user removed a node from the graph.

https://flowbased.github.io/fbp-protocol/#graph-removenode

sendChangeNode (node: Node)

Send a “graph:changenode” message. To use after the user changed any metadata of the node.

https://flowbased.github.io/fbp-protocol/#graph-updatenode

sendAddEdge (edge: Edge)

Send a “graph:addedge” message. To use after the user added an edge on the graph.

https://flowbased.github.io/fbp-protocol/#graph-addedge

sendRemoveEdge (edge: Edge)

Send a “graph:removeedge” message. To use after the user removed an edge on the graph.

https://flowbased.github.io/fbp-protocol/#graph-removeedge

sendChangeEdge (edge: Edge)

Send a “graph:changeedge” message. To use after the user changed the metadata of an edge.

https://flowbased.github.io/fbp-protocol/#graph-changeedge

async sendFileExplorerGetNodesMsg ()

Send a “filexplorer:getnodes” message. Will received a message containing the file structure of the root directory of the workspace as a tree.

buildPayloadForEdge (edge: Edge): Object

Create a FBPMessage compliant payload object for the given Edge

sleep(ms: number)

Pause the execution of a function for the given amount of milliseconds.