Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Device"/> class.
        /// </summary>
        /// <param name="frontendSocket">
        /// A <see cref="ZmqSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
        /// </param>
        /// <param name="backendSocket">
        /// A <see cref="ZmqSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
        /// </param>
        /// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
        protected Device(ZmqSocket frontendSocket, ZmqSocket backendSocket, DeviceMode mode)
        {
            if (frontendSocket == null)
            {
                throw new ArgumentNullException("frontendSocket");
            }

            if (backendSocket == null)
            {
                throw new ArgumentNullException("backendSocket");
            }

            FrontendSocket = frontendSocket;
            BackendSocket = backendSocket;
            FrontendSetup = new DeviceSocketSetup(FrontendSocket);
            BackendSetup = new DeviceSocketSetup(BackendSocket);
            DoneEvent = new ManualResetEvent(false);

            _poller = new Poller();
            _runner = mode == DeviceMode.Blocking ? new DeviceRunner(this) : new ThreadedDeviceRunner(this);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Device"/> class.
        /// </summary>
        /// <param name="frontendSocket">
        /// A <see cref="ZmqSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
        /// </param>
        /// <param name="backendSocket">
        /// A <see cref="ZmqSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
        /// </param>
        /// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
        protected Device(ZmqSocket frontendSocket, ZmqSocket backendSocket, DeviceMode mode)
        {
            if (frontendSocket == null)
            {
                throw new ArgumentNullException("frontendSocket");
            }

            if (backendSocket == null)
            {
                throw new ArgumentNullException("backendSocket");
            }

            FrontendSocket = frontendSocket;
            BackendSocket  = backendSocket;
            FrontendSetup  = new DeviceSocketSetup(FrontendSocket);
            BackendSetup   = new DeviceSocketSetup(BackendSocket);
            DoneEvent      = new ManualResetEvent(false);

            _poller = new Poller();
            _runner = mode == DeviceMode.Blocking ? new DeviceRunner(this) : new ThreadedDeviceRunner(this);
        }