I would encapsulate the higher level functions in an interface with a method
SendMessage
and an event
MessageReceived
. You can then write concrete implementations for whatever communication layers you need.
You can then write a class with methods specific to your protocol, like
GetWidgetCount
, that use the interface. This is like the State pattern. To use a particular concrete implementation, you would just have to change the line:
ICommunicate communicator = new TcpIpCommunicator();
Nick