Ejemplo n.º 1
0
        public static ServiceProxyServer Serve(this CoreServices.ServiceRegistry registry, HostPrefix[] hostPrefixes, ILogger logger = null, BamConf conf = null)
        {
            conf   = conf ?? BamConf.Load(ServiceConfig.ContentRoot);
            logger = logger ?? Log.Default;

            ServiceProxyServer server = new ServiceProxyServer(registry, new ServiceProxyResponder(conf, logger), logger);

            foreach (HostPrefix prefix in hostPrefixes)
            {
                server.HostPrefixes.Add(prefix);
            }
            server.Start();
            return(server);
        }
Ejemplo n.º 2
0
 public void RegisterPendingAsyncExecutionRequest(AsyncExecutionRequest request, Action <AsyncExecutionResponse> handler)
 {
     Args.ThrowIfNull(request);
     Args.ThrowIfNullOrEmpty(request.Cuid);
     lock (_serverLock)
     {
         if (_server == null)
         {
             _server = this.Serve(HostPrefix, Logger);
         }
     }
     SaveExecutionRequestData(request);
     if (!_pendingRequests.TryAdd(request.Cuid, handler))
     {
         Logger.Warning("Failed to register pending request: {0}", request.PropertiesToString());
         FireEvent(AddPendingFailed, new AsyncExecutionRequestEventArgs {
             Request = request
         });
     }
 }