コード例 #1
0
ファイル: WebServer.cs プロジェクト: doristchen/web-app-HOL
        public IAsyncAction StartAsync(Uri baseUri, SuperCacheConfig configuration)
        {
            var window = Windows.UI.Core.CoreWindow.GetForCurrentThread();

            if (window != null)
            {
                this.coreDispatcher = window.Dispatcher;
            }

            this.context = System.Threading.SynchronizationContext.Current;
            return(this.Initialize(baseUri, configuration).AsAsyncAction());
        }
コード例 #2
0
ファイル: WebServer.cs プロジェクト: doristchen/web-app-HOL
        private async Task Initialize(Uri baseUri, SuperCacheConfig configuration)
        {
            this.baseUri       = baseUri;
            this.configuration = configuration;
            this.activityId    = Guid.NewGuid();
            Trace.TraceLevel   = configuration.TraceLevel;
            Trace.Information(this.activityId, "Server is starting...");

            HostName hostName = null;
            string   port     = string.Empty;

            if (!configuration.ProxyUri.Equals(SuperCacheConfig.AutomaticProxyUriConfiguration, StringComparison.OrdinalIgnoreCase))
            {
                // use manual configuration
                Uri proxyUri;
                if (!Uri.TryCreate(configuration.ProxyUri, UriKind.Absolute, out proxyUri))
                {
                    throw new InvalidOperationException("An invalid value was specified for the ProxyUri configuration setting.");
                }

                hostName = new HostName(proxyUri.Host);
                port     = proxyUri.Port.ToString();
            }

            // start socket listener
            this.listener = new StreamSocketListener();
            this.listener.ConnectionReceived += (sender, args) => { Task.Run(async() => { await this.OnConnectionReceivedAsync(sender, args); }); };
            await this.listener.BindEndpointAsync(hostName, port);

            // build proxy URI from the actual port bound to the listener
            this.proxyUri = new Uri(
                "http://" +
                (hostName != null ? hostName.CanonicalName : LocalhostIpAddress) +
                ":" +
                this.listener.Information.LocalPort);

            // initialize cookie manager
            this.cookieManager = new CookieManager(this.proxyUri);
            await this.cookieManager.LoadCookiesAsync(this.activityId);

            // initialize list of preload scripts
            await this.InitializePreloadScriptsAsync();

            Trace.Information(this.activityId, "Server is listening on port: {0} - baseUri: {1}", this.listener.Information.LocalPort, this.baseUri);
        }
コード例 #3
0
ファイル: WebServer.cs プロジェクト: deltakosh/Coding4Fun
        private async Task Initialize(Uri baseUri, SuperCacheConfig configuration)
        {
            this.baseUri = baseUri;
            this.configuration = configuration;
            activityId = Guid.NewGuid();
            Trace.TraceLevel = configuration.TraceLevel;
            Trace.Information(activityId, "Server is starting...");

            HostName hostName = null;
            string port = string.Empty;
            if (!configuration.ProxyUri.Equals(SuperCacheConfig.AutomaticProxyUriConfiguration, StringComparison.OrdinalIgnoreCase))
            {
                // use manual configuration
                Uri proxyUri;
                if (!Uri.TryCreate(configuration.ProxyUri, UriKind.Absolute, out proxyUri))
                {
                    throw new InvalidOperationException("An invalid value was specified for the ProxyUri configuration setting.");
                }

                hostName = new HostName(proxyUri.Host);
                port = proxyUri.Port.ToString();
            }

            // start socket listener 
            listener = new StreamSocketListener();
            listener.ConnectionReceived += (sender, args) => { Task.Run(async () => { await OnConnectionReceivedAsync(sender, args); }); };
            await listener.BindEndpointAsync(hostName, port);

            // build proxy URI from the actual port bound to the listener
            this.proxyUri = new Uri(
                "http://" +
                (hostName != null ? hostName.CanonicalName : LocalhostIpAddress) +
                ":" +
                listener.Information.LocalPort);

            // initialize cookie manager
            cookieManager = new CookieManager(this.proxyUri);
            await cookieManager.LoadCookiesAsync(activityId);

            // initialize list of preload scripts
            await InitializePreloadScriptsAsync();

            Trace.Information(activityId, "Server is listening on port: {0} - baseUri: {1}", listener.Information.LocalPort, this.baseUri);
        }
コード例 #4
0
ファイル: WebServer.cs プロジェクト: deltakosh/Coding4Fun
        public IAsyncAction StartAsync(Uri baseUri, SuperCacheConfig configuration)
        {
            var window = Windows.UI.Core.CoreWindow.GetForCurrentThread();
            if (window != null)
            {
                coreDispatcher = window.Dispatcher;
            }

            context = System.Threading.SynchronizationContext.Current;
            return Initialize(baseUri, configuration).AsAsyncAction();
        }
コード例 #5
0
 public static IAsyncAction StartAsync(Uri baseUri, SuperCacheConfig configuration)
 {
     webServer = new WebServer();
     return(webServer.StartAsync(baseUri, configuration));
 }