These instructions assume your modules are initialised and have registered their components and communication interfaces. The WinGate Module Wizard can do this for you.

 

Here is a basic overview of the typical process of establishing a connection between UI and Engine components.

When your UI component is ready to start, the UI Host (WinGate Management Console) calls your ComponentEntry.Start function. In this function typically you call CommsConnect to initiate a connection to an Engine-side component. 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;
}

 

When the Engine receives this request it looks for a registered ComponentCommunicationsInterface interface for the specified UUID (MY_COMPONENT_ENGINE_UUID). If found, it calls the ComponentCommunicationsInterface.Accept function for that component. The Accept 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))
 	{
		return false; // deny the connection
	}
/* Save the connection handle for later. You should serialise (protect with locks) access to the connections container because multiple WMCs might be attempting to connect at the same time, and each is in a different thread. */
	connections[sourceUuid] = connection;
	return true;
}

 

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

This is an example of storing the connection associated with a connection peer. The reason we use a container and not a single connection 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. see Propagating configuration changes

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

Once ComponentCommunicationsInterface.Connected has been processed, both modules are now able to send messages between each other with CommsSend.

 

void Connected(void* connection, bool bConnected)
{
	if(!bConnected)
 	{
		// connection was rejected, usually for permissions reason
		return;
	}
	// save the connection handle to our peer
	// send initial protocol packet, usually requesting the engine to send configuration settings
}

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.