Ejemplo n.º 1
0
 public async Task EmbedIOChannel()
 {
     using (var webServer = new Unosquare.Labs.EmbedIO.WebServer("http://+:8000/", Unosquare.Labs.EmbedIO.Constants.RoutingStrategy.Regex))
         using (var subscriptionApi = new EmbedIOSubscriptionApi(webServer, path: "/ws", mustReceiveHeartbeatMillis: 2000, getAuthToken: (authType, authValue) => authValue, getId: authToken => authToken.ToString())) {
             await ChannelUnitTest.TestChannel(subscriptionApi, "ws://localhost:8000/ws", () => {
                 webServer.RunAsync();
             });
         }
 }
Ejemplo n.º 2
0
 public async Task EmbedIOWeb()
 {
     using (var webServer = new Unosquare.Labs.EmbedIO.WebServer("http://+:8000/", Unosquare.Labs.EmbedIO.Constants.RoutingStrategy.Regex))
         using (var webApi = new EmbedIOWebApi(webServer)) {
             await WebApiUnitTest.TestWeb(webApi, "http://localhost:8000/", () => {
                 webServer.RunAsync();
             });
         }
 }
Ejemplo n.º 3
0
        public EmbedIOContext(string url, string staticPath = null)
        {
            // Binding to all local IP addresses requires adding an HTTP URL ACL rule
            // This may prompt to "allow app to modify your device"
            ProcessX.AddHttpUrlAclIfNeeded(url);

            // Create the underlying EmbedIOWebServer (see https://github.com/unosquare/embedio)
            this.webServer = new Unosquare.Labs.EmbedIO.WebServer(url);
            if (!string.IsNullOrEmpty(staticPath))
            {
                logger.Debug($"EmbedIOContext():staticPath={staticPath}");
                this.webServer.RegisterModule(new StaticFilesModule(staticPath, headers: new System.Collections.Generic.Dictionary <string, string> {
                    ["Cache-Control"] = "no-cache, no-store, must-revalidate",
                    ["Pragma"]        = "no-cache",
                    ["Expires"]       = "0"
                }));
            }
            //Unosquare.Swan.Terminal.Settings.DisplayLoggingMessageType = Unosquare.Swan.LogMessageType.Trace;

            // Create the IWebApi and ISubscriptionApi wrappers
            this.webApi          = new EmbedIOWebApi(webServer);
            this.subscriptionApi = new EmbedIOSubscriptionApi(webServer, path: "/ws");
        }