Exemple #1
0
        public async Task WebTest()
        {
            var webServer = new Red.RedHttpServer(8000);

            using (var webApi = new RedHttpServerWebApi(webServer)) {
                await WebApiUnitTest.TestWeb(webApi, "http://localhost:8000/", () => {
                    webServer.Start();
                });
            }
            await webServer.StopAsync();
        }
Exemple #2
0
        public async Task ChannelTest()
        {
            var webServer = new Red.RedHttpServer(8000);

            using (var subscriptionApi = new RedHttpServerSubscriptionApi(webServer, path: "/ws", mustReceiveHeartbeatMillis: 2000, getAuthToken: (authType, authValue) => authValue, getId: authToken => authToken.ToString())) {
                await ChannelUnitTest.TestChannel(subscriptionApi, "ws://localhost:8000/ws", () => {
                    webServer.Start();
                });
            }
            await webServer.StopAsync();
        }
        public RedHttpServerContext(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 RedHttpServer (see https://github.com/rosenbjerg/Red)
            this.webServer = new Red.RedHttpServer(8000, staticPath);

            // Create the IWebApi and ISubscriptionApi wrappers
            this.webApi = new RedHttpServerWebApi(webServer);
            this.subscriptionApi = new RedHttpServerSubscriptionApi(webServer, path: "/ws");
        }
Exemple #4
0
 public void Setup()
 {
     _server     = new Red.RedHttpServer(TestPort);
     _httpClient = new HttpClient();
 }