Ejemplo n.º 1
0
        /// <summary>
        /// Wrap the custom handler with our instrumentation handlers.
        /// Additional observers may be added once the board is initialized
        /// </summary>
        /// <param name="customHandler">additional handler provided by object creator. </param>
        /// <param name="customHandler">observers added to the default handler. </param>
        private void ConfigureHandlers(IIncomingHandlerIOIO customHandler, List <IObserverIOIO> observers)
        {
            // we want this one to be blocking so that outbound wait for resources
            CaptureOutboundObservable_ = new IOIOHandlerObservable();
            // we want this one to be non blocking
            CaptureInboundObservable_ = new IOIOHandlerObservableNoWait();

            CapturedConnectionInformation_ = new ObserverConnectionState();
            CaptureInboundObservable_.Subscribe(CapturedConnectionInformation_);
            // add the passed in observers
            // observers using the default handler threading model
            if (observers != null)
            {
                foreach (IObserverIOIO oneObserver in observers)
                {
                    CaptureInboundObservable_.Subscribe(oneObserver);
                }
            }
            // probably observers attached to something other than the default threading model
            if (customHandler != null)
            {
                InboundHandler_ = new IOIOHandlerDistributor(
                    new List <IIncomingHandlerIOIO> {
                    CaptureInboundObservable_, customHandler
                });
            }
            else
            {
                InboundHandler_ = CaptureInboundObservable_;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// This lets you add a custom handler if you want to pick one of the other threading models
 /// for your observers
 /// </summary>
 /// <param name="conn"></param>
 /// <param name="customHandler">your handler.  This always adds:
 ///     IOIOHandlerCaptureConnectionState , IOIOHandlerCaptureLog</param>
 public IOIOImpl(IOIOConnection conn, IIncomingHandlerIOIO customHandler)
 {
     if (conn == null)
     {
         throw new IllegalStateException("Silly Rabbit: You can't create an IOIOImpl without a connection!");
     }
     this.Conn_ = conn;
     ConfigureHandlers(customHandler, null);
 }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="Stream_">incoming Stream_ from the IOIO</param>
 /// <param name="handler">handler or handler distributor that will added to the notification list</param>
 /// <param name="cancelTokenSource">A cancellation token so that this will be stopped with other threads. Creates a token if none passed in</param>
 public IOIOProtocolIncoming(Stream stream, IIncomingHandlerIOIO handler, CancellationTokenSource cancelTokenSource)
 {
     this.Stream_  = stream;
     this.Handler_ = handler;
     if (cancelTokenSource != null)
     {
         CancelTokenSource_ = cancelTokenSource;
     }
     else
     {
         CancelTokenSource_ = new CancellationTokenSource();
     }
     IncomingTask_ = new Task(run, CancelTokenSource_.Token, TaskCreationOptions.LongRunning);
     IncomingTask_.Start();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// This object will generate its own cancellation token
 /// </summary>
 /// <param name="Stream_"></param>
 /// <param name="handler"></param>
 public IOIOProtocolIncoming(Stream stream, IIncomingHandlerIOIO handler) :
     this(stream, handler, new CancellationTokenSource())
 {
     // constructor exists only for constructor chaining
 }