CreateSym3
Create the sym3.js API object – most functions in this documentation (other than the ones in the “Functions” section) are called through an instance of the object returned by this function.
sym3.js will try to make a connection to the specified server with no further interaction than calling this function. Note that most functions will only have an effect if the project is loaded. Use SetOnProjectInitialised to detect when you can start calling the other functions.
sym3.js automatically handles:
- Tab visibility detection - Monitors when browser tab is hidden/visible
- View state saving - Saves the view state (current view matrix, background colour, highlight mode, options) when tab is hidden
- Connection monitoring - Checks if connection was lost while tab was hidden
- Auto-reconnection - Attempts to reconnect if connection was lost
- View state restoration - restore the previously saved view state after successful reconnection
You don’t need to implement any of this logic. Use SetOnReconnecting function if you want to be notified so you can update your UI!
Function
CreateSym3(port: number, serverName: string, webSocketSecure: boolean, replayMode: boolean, senderIpAddress: number)
Parameters:
- port (int): the port number to connect to the Sym3 Operator server with.
- serverName (string): the server name to connect to. If not supplied, defaults to location.hostname.
- webSocketSecure (bool): use a secure WebSocket connection (wss) to connect to the server. Requires that the server has a TLS certificate set up correctly. If not supplied, defaults to false.
- replayMode (boolean, optional): Indicates that the web client will use the Sym3 Replay server to connect and replay instead of the live Operator server. If not supplied, defaults to false.
- senderIpAddress senderIpAddress (number, optional): IPv4 address of the client, encoded as a 32-bit integer and submitted to the Sym3 Operator server with each request. If not supplied, defaults to 0 (no sender address sent).
Return Value
The instantiated Sym3 API object.
Example
Create the API object to wss://localhost:2345 and call a member function.
let SYM3 = CreateSym3(2345, "localhost", true);
SYM3.GetState();