Esempio n. 1
0
        /// <summary>
        /// Complete second phase startup for this service
        /// </summary>
        protected override void Start()
        {
            _fwdPort    = ServiceForwarder <WebCamServiceOperations>(ServiceInfo.Service);
            _altFwdPort = ServiceForwarder <webcam.WebCamOperations>(AlternateContractServiceInfo[0].Service);

            _utilitiesPort = DsspHttpUtilitiesService.Create(Environment);

            _prefix          = new Uri(ServiceInfo.Service).AbsolutePath;
            _alternatePrefix = new Uri(AlternateContractServiceInfo[0].Service).AbsolutePath;

            if (_state == null)
            {
                _state = new WebCamState();
            }

            base.ActivateDsspOperationHandlers();

            if (_state.FramesOnDemand)
            {
                _framesOnDemand = true;
                Activate(Arbiter.ReceiveWithIterator(true, _framePort, OnDemandFrameHandler));
            }
            else
            {
                base.MainPortInterleave.CombineWith(
                    Arbiter.Interleave(
                        new TeardownReceiverGroup(),
                        new ExclusiveReceiverGroup
                        (
                            Arbiter.Receive(true, _framePort, FrameHandler)
                        ),
                        new ConcurrentReceiverGroup()
                        )
                    );
            }

            StartPipeServer();

            SpawnIterator(_state, GetInitialState);
        }
Esempio n. 2
0
        /// <summary>
        /// Service startup
        /// </summary>
        protected override void Start()
        {
            _fwdPort       = ServiceForwarder <webcam.WebCamOperations>(ServiceInfo.Service);
            _utilitiesPort = DsspHttpUtilitiesService.Create(Environment);

            Uri httpAlias = ServiceInfo.HttpServiceAlias;

            if (httpAlias != null)
            {
                _prefix            = httpAlias.AbsolutePath;
                _alternatePrefixes = AlternateContractServiceInfo.ConvertAll <string>(
                    delegate(ServiceInfoType alternate)
                {
                    return(alternate.HttpServiceAlias.AbsolutePath);
                }
                    );
            }

            try
            {
                _streamPort = mdwebcam.ReadStream.Create(_state.CaptureFile, Environment.TaskQueue);
            }
            catch (Exception e)
            {
                LogError("Unable to open stream file: " + e.Message);
                base.StartFailed();
                return;
            }

            base.Start();

            base.MainPortInterleave.CombineWith(
                new Interleave(
                    new ExclusiveReceiverGroup(
                        Arbiter.Receive <mdwebcam.Frame>(true, _streamPort, ReadFrameHandler)
                        ),
                    new ConcurrentReceiverGroup()
                    )
                );
        }