/// <summary> /// Redirects the HTTP request from an alternate contract to a partner /// </summary> /// <param name="contract">The contract.</param> /// <param name="partner">The partner.</param> /// <param name="context">The context.</param> /// <param name="responsePort">The response port.</param> private void RedirectHttpRequest( string contract, IPort partner, HttpListenerContext context, PortSet <HttpResponseType, Fault> responsePort) { var alternate = AlternateContractServiceInfo.Find(s => s.Contract == contract) ?? ServiceInfo; var basePath = alternate.HttpServiceAlias.AbsolutePath; var requestedPath = context.Request.Url.PathAndQuery; var pathSuffix = requestedPath.Substring(basePath.Length); var lookup = new DsspDefaultLookup(); partner.PostUnknownType(lookup); this.Activate( lookup.ResponsePort.Choice( svcinfo => { var redirectPath = svcinfo.HttpServiceAlias.AbsolutePath + pathSuffix; context.Response.Redirect(redirectPath); context.Response.Close(); responsePort.Post(new HttpResponseType()); }, responsePort.Post)); }
/// <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() ) ); }