Exemple #1
0
        private void StartHttpButton_Click(object sender, RoutedEventArgs e)
        {
            if (!(sender is Button button))
            {
                return;
            }
            try
            {
                var httpUrl = Queryservice.GetHttpUri();
                HttpServer = new HproseHttpListenerServer(httpUrl);
                HttpServer.Add("Expjson", enQrCodeService);
                HttpServer.Add("Encoder", enQrCodeService);
                HttpServer.Start();

                HttpServer.OnAfterInvoke += TcpServer_OnAfterInvoke;

                ListBoxServerMsg.Items.Insert(0, "Http服务启动成功:" + DateTime.Now.ToString());

                button.IsEnabled         = false;
                StopHttpButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                ListBoxServerMsg.Items.Insert(0, "Http服务启动错误:" + ex.Message);
            }
        }
        static void Main(string[] args)
        {
            HproseClassManager.Register(typeof(User), "User");
            HproseHttpListenerServer server = new HproseHttpListenerServer("http://localhost:2012/");
            TestService ts = new TestService();

            server.Add("Hello", ts, true);
            server.Add("SendUsers", ts);
            server.IsCrossDomainEnabled = true;
            //server.CrossDomainXmlFile = "crossdomain.xml";
            server.Start();
            Console.WriteLine("Server started.");
            Console.ReadLine();
            Console.WriteLine("Server stopped.");
        }
Exemple #3
0
        static void Main(string[] args)
        {
            HproseTcpListenerServer tcpserver = new HproseTcpListenerServer("tcp4://127.0.0.1:4321/");

            tcpserver.Add("Hello", typeof(Program));
            tcpserver.Start();
            HproseHttpListenerServer httpserver = new HproseHttpListenerServer("http://localhost:8888/");

            httpserver.Add("Hello", typeof(Program));
            httpserver.Start();
            Console.ReadKey();
            tcpserver.Stop();
            httpserver.Stop();
        }
Exemple #4
0
        static void AddClass(Type t)
        {
            server.Add(t);
            var att1 = t.GetCustomAttribute(typeof(SafeAttribute)) != null;
            var att2 = t.GetCustomAttribute(typeof(UnSafeAttribute)) != null;
            var att3 = t.GetCustomAttribute(typeof(LoginAttribute)) != null;

            var fs = t.GetMethods(BindingFlags.Public | BindingFlags.Static);

            foreach (var f in fs)
            {
                var att4 = f.GetCustomAttribute(typeof(SafeAttribute)) != null;
                var att5 = f.GetCustomAttribute(typeof(UnSafeAttribute)) != null;
                var att6 = f.GetCustomAttribute(typeof(LoginAttribute)) != null;
                if (att4 || (att1 && !att5))
                {
                    SaveFunc.Add(f.Name);
                }
                if (att6 || (att3 && !att4 && !att5))
                {
                    UserSaveFunc.Add(f.Name);
                }
            }
        }