Setting up communication between UI and Engine modules

When your UI component is ready to start, the UI Host (WinGate Management Console) calls your ComponentEntry.Start function. In this function you call CommsConnect. e.g.

int Start(ComponentEntry* entry)
{
	CommsConnect(entry, MY_COMPONENT_ENGINE_UUID); /* Asks the framework to attempt a comms connection to component with UUID MY_COMPONENT_ENGINE_UUID */
	return 0;
}

 

The UI Host then sends a connection request to the Engine. When the Engine receives this, it looks for a ComponentCommunicationsInterface registered by the component with the specified UUID (MY_COMPONENT_ENGINE_UUID). If found, it calls the ComponentCommunicationsInterface.CommsAccept function for that component. The CommsAccept function is where your Engine component can decide whether to accept the connection or not.

bool Accept(void* connection, const GUID &sourceUuid)
{
	if(!IsEqualGUID(sourceUuid, MY_COMPONENT_UI_UUID)) /* Only allow our UI peer(s) */
 	{
		return false;
	}
/* Save the connection for later. You probably want to lock before changing the connections container */
	connections[sourceUuid] = connection;
	return true;
}

 

 Notice in the example code above that we have the line
connections[sourceUuid] = connection;

This is just an example of storing the connection associated with an connection peer and our example is assuming you have an std::map called connections of UUIDs to void *. The reason we use a container is because an engine component might have more than one UI component connected to it, typically when there are multiple WinGate Management Consoles connected to the same WinGate engine. By saving these connections you can send data to multiple WMCs at the same time. This is typically how configuration changes are propogated.

 

If your Engine module accepts the connection (By returning true) then WinGate informs the WMC which then calls your module's ConnectedComponentCommunicationsInterface.CommsConnected function. Your UI module then typically saves the connection somewhere for use later.

NOTE: You should be prepared to handle multiple incoming connections from different WinGate Engines, even though at present only one is possible.

Once ConnectedComponentCommunicationsInterface.CommsConnected has been processed, both modules are now able to send messages between each other.