예제 #1
0
 public PortWrapper(IPort port, string id, PortSettings settings, Action <PortWrapper, byte[], CancellationToken> onRecv)
 {
     _onRecv  = onRecv;
     Port     = port;
     Id       = id;
     Settings = settings;
     port.Subscribe(OnNext, _cancel.Token);
 }
예제 #2
0
 public void Add(PortSettings settings)
 {
     lock (_sync)
     {
         var port = PortFactory.Create(settings.ConnectionString);
         if (settings.IsEnabled)
         {
             port.Enable();
         }
         else
         {
             port.Disable();
         }
         _ports.Add(new PortWrapper(port, Guid.NewGuid().ToString(), settings, OnRecv));
     }
     _configChangedSubject.OnNext(Unit.Default);
 }