From iLab Cookbook

Toolkits: HowToGetTheSharedDictionary

<< Back to the SharedPhidgets page


You can get a reference to the shared dictionary that is used by all the SharedPhidgets components and skins. This lets you read and modify entries in the shared dictionary directly.

Note: this is only recommended for advanced developers! Be aware that by changing wrong entries in the dictionary, the complete SharedPhidgets infrastructure might become instable.

Note: you need the GroupLab .Networking toolkit to work with a shared dictionary and subscriptions

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

GroupLab.Networking.SharedDictionary sharedDictionary =
  connectionManager.getSharedDictionary();

Then you can setup a new subscription object that receives all the entries in the shared dictionary:

GroupLab.Networking.Subscription subscription
  = new GroupLab.Networking.Subscription();

subscription.BeginInit();
subscription.Dictionary = sharedDictionary;
subscription.Pattern = "/*";
subscription.Notified
  +=new GroupLab.Networking.SubscriptionEventHandler(subscription_Notified);
subscription.Enabled = true;
subscription.EndInit();

You also need this callback method of the notification event handler:

private void subscription_Notified(object sender, GroupLab.Networking.SubscriptionEventArgs e)
{
  string path = e.Path;
  object receivedValue = e.Value;

  // Your code here
}



Retrieved from http://grouplab.cpsc.ucalgary.ca/cookbook/index.php/Toolkits/HowToGetTheSharedDictionary
Page last modified on January 24, 2006, at 02:27 PM