How To Manually Use The Connection Manager

<< Back to the SharedPhidgets page

Besides using the Appliance base class, or the development template of Visual Studio, it is possible to use the connection manager to open and close connections to a shared dictionary server instance. The connection manager object is resposible for establishing the connection to the shared dictionary that stores the model entries of the shared hardware devices.

Method 1: Creating object in the code

GroupLab.SharedPhidgets.ConnectionManager connectionManager
  = new GroupLab.SharedPhidgets.ConnectionManager();

Or: If you have created your own class (e.g., main class of the application), just add a private member to the class and create the object in your class constructor:

private GroupLab.SharedPhidgets.ConnectionManager connectionManager;

public Form1()
  this.connectionManager = new GroupLab.SharedPhidgets.ConnectionManager();

Note: you can create more instances of the connection manager, however, all of these managers will control only a single shared dictionary with the same address. This is, because the internal connection object is build as Singleton (see: Erich Gamma, Design Patterns) and passes this singleton object to all classes that need a connection.

When you have created the connection manager object, you can simply connect to a Shared Phidgets server by specifying the TCP address (replace localhost with the IP address you want to connect to):

connectionManager.SharedDictionaryURL = "tcp://localhost:sp";

You can disconnect from this server by simply using the closeConnection() method:


In the same way, you can simply connect to another server by changing the SharedDictionaryURL property of the object. First, disconnect from the server, change the address, and finally reconnect to the server:

connectionManager.SharedDictionaryURL = "tcp://newhost:sp";

Method 2: Creating a ConnectionManagerSkin

1) Select the SharedPhidgets toolbox in Visual Studio, and click on the ConnectionManagerSkin button.

2) Click on your form and you can see the interface control of the ConnectionManagerSkin. When the application is started, the user can change the IP address and connect.