Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

...

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.CommsAccept function Accept function for that component. The CommsAccept Accept function is where your Engine component can decide whether to accept the connection or not.

Code Block
languagecpp
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;
}

...

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

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

 

Info

At present a UI module can only ever have one incoming connection but you should be prepared to handle more than one for future expansion.

 

Code Block
languagecpp
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

Content by Label
spacesWINGATESDK
reversetrue
showLabelsfalse
max5
sortmodified
labelsuienginecomms
showSpacefalse
typepage