WebSocket API
Note: Use of the Websockets is not support with the Fusion engine.
When using Design Automation directly from a client device (for example, a desktop machine, mobile phone, or laptop) you cannot set up onComplete or onProgress arguments that point back to the client device. This forces these applications to make repeated GET requests to find the progress of a workitem. This is inefficient and, due to increased energy use, contributes to global warming. Therefore Design Automation offers WebSocket endpoints.
Developer’s Guide
You can use the WebSocket API for any client that can issue conforming WebSocket requests. You can use it from the browser by using the standard websocket API. You can use it from the command line (for example using wscat). You can use any other library or toolset you want. Examples in this guide will use wscat. The following example uses 2-legged tokens. For most production scenarios, you should use a 3-legged token. Please review the background information for how to use 3-legged tokens with FDA.
The host you target is websockets.forgedesignautomation.io.
To connect using wscat use the following command:
wscat -c wss://websockets.forgedesignautomation.io
wscat prompts as follows:
connected (press CTRL+C to quit)
>
You can now send requests. Type any string. For example:
> hello
< {"action":"error","data":"Invalid payload. Unexpected character
encountered while parsing value: h. Path '', line 0, position 0."}
To get something more useful, you need a token, which you can obtain following the same steps that you follow when making HTTP requests. Then you can type the following command (replace <your token> with your bearer token).
> { "action" : "post-workitem", "data" : { "activityId" :
"Autodesk.Nop+Latest"}, "headers": {"Authorization": "Bearer <your
token>"}}
< {"action":"status","data":{"status":"pending","stats":{"timeQueued":"2021-02-20T16:36:00.5367829Z"},"id":"6e13bd3b520142f6887e7333b8251e84"}}
After a while, you receive a response similar to the following:
{"status":"success","reportUrl":"https://dasprod-store.s3.amazonaws.com/workItem/CokbOqRvp41DVunD7lBO2ciiwJpltTAf/6e13bd3b520142f6887e7333b8251e84/report.txt?AWSAccessKeyId=...","stats":{"timeQueued":"2021-02-20T16:36:00.655Z","timeDownloadStarted":"2021-02-20T16:36:00.7227303Z","
timeInstructionsStarted":"2021-02-20T16:36:01.1628287Z","timeInstructionsEnded":"2021-02-20T16:36:04.4070839Z","timeUploadEnded":"2021-02-20T16:36:04.7794786Z","bytesDownloaded":100,"bytesUploaded":100},"id":"6e13bd3b520142f6887e7333b8251e84"}
For more detailed information, see the websocket reference.