Versions Compared

Key

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

...

In order to share this object, it must be registered by the device which configures it. To do this, we can use the following:. In this example, we are use the GroupKey as the object key. This effectively scopes this shared object to all channels within this group.

Code Block
languagec#
using Connexion.Core;
using Shared;
using System;

namespace ConfigOwnerDevice
{
    [DevicePlugin("Configuration Master Device", "Hosts a shared configuration", DeviceDefinitionFlags.NonProcessingDevice, typeof(object), typeof(object), typeof(SingletonTestingFactory))]
    public class ConfigOwnerDevice: BaseDevice<SharedConfiguration>
    {
        public ConfigOwnerDevice(Guid deviceKey, IMessageChannelDevice messageChannelDevice)
          : base(deviceKey, messageChannelDevice)
        {
        }

        public override void Load(string configuration)
        {
            base.Load(configuration);
            // register our configuration for other devices to read
            MessageChannel.ObjectRegistryService.Register(MessageChannel.GroupKey, Configuration);
        }
    }
}

...