コード例 #1
0
        async void DoHttp()
        {
            var t = new TcpTransport();

            RobotRaconteurNode.s.RegisterTransport(t);

            RobotRaconteurNode.s.RegisterServiceType(new com.robotraconteur.testing.TestService1.com__robotraconteur__testing__TestService1Factory());
            RobotRaconteurNode.s.RegisterServiceType(new com.robotraconteur.testing.TestService2.com__robotraconteur__testing__TestService2Factory());
            RobotRaconteurNode.s.RegisterServiceType(new com.robotraconteur.testing.TestService3.com__robotraconteur__testing__TestService3Factory());

            var s = new RobotRaconteurTestServiceSupport();

            s.RegisterServices(t);

            var s2 = new RobotRaconteurTestServiceSupport2();

            s2.RegisterServices(t);


            var listener = new HttpListener();

            listener.Prefixes.Add("http://localhost:60080/robotraconteurtest/");
            listener.Start();

            while (true)
            {
                var c = await listener.GetContextAsync();

                if (c.Request.IsWebSocketRequest)
                {
                    var ws_context = await c.AcceptWebSocketAsync("robotraconteur.robotraconteur.com");

                    t.AcceptAndProcessServerWebSocket(ws_context.WebSocket, ws_context.RequestUri.ToString()).ContinueWith(x => { });
                }
                else
                {
                    c.Response.StatusCode = 400;
                    c.Response.Close();
                }
            }
        }