Connecting your client to Event Manager

If there is an Event Manager Websocket server running somewhere, you can now connect to it to send and receive events.
Let us see how to do so.
In order to connect your client to event manager, you must follow a few steps.

First you should use the standard websocket connection method of calling wss:// where you replace with the IP address to your server and 9002 with the port number you specified in the websocket config file on the server.

The event manager always utilizes TLS security, so ensure your provided keys are correct and match for the server and client.
In order for event manager to authorize any client, it requires that a special key is added to the websocket handshake header.
This ensures the safety of all incoming connections.

If you have specified an authenticiation key and authentication value in your websocket config file then you'll need to add the key and value to your header like so:

"<authentication_key>": "<authentication_value>"

At any given point while trying to establish a connection, watch your terminal on the server for helpful debugging messages.

For a client to make a request it must simply create a JSON message and pass it to the websocket server.
When the server receives your request, it will be processed and a JSON response with the following key-value pairs will be returned to you:

"Status": "string - either OK or ERROR. OK indicates a success while ERROR indicates a failure to fulfill request",
"Error Code": "imm_error_code - an enum value from the imm_error_code enumeration",
"Error Description": "string - a description of what went wrong if there was an error",
"Request": JSON - the JSON object that was originally requested,
"value": string / int - additional information you requested, such as get participant state

Note that if you receive "Status": "OK", then you will not see a key-value pair for "Error Description" in your response JSON.
Additionally, you will only receive "Value" or other key-value pairs if your original request was asking for a value.
Your request may provide additional output parameters if they are relevant, and would be described in the full Event Manager API.

Sometimes a host program may perform actions without the request of a client.
In this case, the server will want to keep the client up to date by sending a message to the client about an event that occurred.
If an event occurred, you will see a JSON formatted message with the following key-value pairs:

"Event": "string - describing what event occurred",
"values": "string / integer_value - providing additional information about the event"

To see a full list of events that may be triggered, view imm_event_type