当前位置: 首页>>代码示例>>C#>>正文


C# Http.HttpChannel类代码示例

本文整理汇总了C#中System.Runtime.Remoting.Channels.Http.HttpChannel的典型用法代码示例。如果您正苦于以下问题:C# HttpChannel类的具体用法?C# HttpChannel怎么用?C# HttpChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpChannel类属于System.Runtime.Remoting.Channels.Http命名空间,在下文中一共展示了HttpChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitRemoteCalculator

        private static void InitRemoteCalculator()
        {
            WellKnownObjectMode objectMode;
            objectMode = WellKnownObjectMode.SingleCall;  // Cada pedido é servido por um novo objecto
            //objectMode = WellKnownObjectMode.Singleton;   // Todos os pedidos servidos pelo mesmo objecto

            IDictionary httpChannelProperties = new Hashtable();
            httpChannelProperties["name"] = "calculatorHttpChannel";
            httpChannelProperties["port"] = 2222;

            IDictionary tcpChannelProperties = new Hashtable();
            tcpChannelProperties["name"] = "calculatorTcpChannel";
            tcpChannelProperties["port"] = 3333;

            IDictionary ipcChannelProperties = new Hashtable();
            ipcChannelProperties["name"] = "calculatorIpcChannel";
            ipcChannelProperties["portName"] = "localhost:9090";

            calculatorHttpChannel = new HttpChannel(httpChannelProperties, null, new SoapServerFormatterSinkProvider());
            calculatorTcpChannel = new TcpChannel(tcpChannelProperties, null, new BinaryServerFormatterSinkProvider());
            calculatorIpcChannel = new IpcChannel(ipcChannelProperties, null, new BinaryServerFormatterSinkProvider());

            ChannelServices.RegisterChannel(calculatorHttpChannel, false);
            ChannelServices.RegisterChannel(calculatorTcpChannel, false);
            ChannelServices.RegisterChannel(calculatorIpcChannel, false);

            RemotingConfiguration.RegisterWellKnownServiceType(
              typeof(RemoteCalculator),
              "RemoteCalculator",
              objectMode);
        }
开发者ID:davidajulio,项目名称:hx,代码行数:31,代码来源:RemoteCalculatorMain.cs

示例2: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Inicio da RemoteCalc");

            //HTTP
            HttpChannel ch = new HttpChannel(1235);

            //TCP
            //TcpChannel ch = new TcpChannel(1235);

            //registar o canal
            ChannelServices.RegisterChannel(ch, false);

            //configurar o remoting para Marshal by Ref
            //RemotingConfiguration.RegisterWellKnownServiceType(
            //                        typeof(RemoteCalc),
            //                        "RemoteCalcServer.soap",
            //                        WellKnownObjectMode.Singleton);
            //                        //WellKnownObjectMode.SingleCall);

            //factory
            RemotingConfiguration.RegisterWellKnownServiceType(
                                    typeof(RemoteCalcFactory),
                                    "RemoteCalcServer.soap",
                                    WellKnownObjectMode.Singleton);

            Console.WriteLine("Server running...press enter to exit");
            Console.ReadLine();
        }
开发者ID:pepipe,项目名称:ISEL,代码行数:29,代码来源:Server.cs

示例3: Main

		static void Main (string [] args)
		{
			DateTime start = DateTime.Now;
			HttpChannel chnl = new HttpChannel ();
#if NET_2_0
			ChannelServices.RegisterChannel (chnl, false);
#else
			ChannelServices.RegisterChannel (chnl);
#endif
			BaseRemoteObject obj = (BaseRemoteObject) Activator.GetObject (typeof (BaseRemoteObject),
				"http://localhost:1237/MyRemoteObject.soap");
			Test test = new Test ();
			test.t = "test";

			obj.test = test;
			SetValueDelegate svd = new SetValueDelegate (obj.setValue);
			IAsyncResult arValSet = svd.BeginInvoke (625, null, null);
			svd.EndInvoke (arValSet);

			GetValueDelegate gvd = new GetValueDelegate (obj.getValue);
			IAsyncResult arValGet = gvd.BeginInvoke (null, null);

			GetTextDelegate gtd = new GetTextDelegate (obj.getText);
			IAsyncResult arTxt = gtd.BeginInvoke (null, null);

			int iVal = gvd.EndInvoke (arValGet);
			string str = gtd.EndInvoke (arTxt);
			TimeSpan elapsed = DateTime.Now - start;

			Assert.AreEqual (625, iVal, "#A1");
			Assert.AreEqual ("Narendra", str, "#A2");

			Assert.IsTrue (elapsed.TotalMilliseconds > 9000, "#B1:" + elapsed.TotalMilliseconds);
			Assert.IsTrue (elapsed.TotalMilliseconds < 12000, "#B2:" + elapsed.TotalMilliseconds);
		}
开发者ID:mono,项目名称:gert,代码行数:35,代码来源:client.cs

示例4: Form1

        public Form1()
        {
            try
            {
                //Windows forms
                InitializeComponent();
                AppDomain myDomain = AppDomain.CurrentDomain;
                this.Text = myDomain.FriendlyName;

                //HTTP
                HttpChannel ch = new HttpChannel(0);

                //TCP
                //TcpChannel ch = new TcpChannel(0);

                ChannelServices.RegisterChannel(ch, false);

                //Marshal by ref object
                //m_calc = (ICalc)Activator.GetObject(
                //    typeof(ICalc),
                //    "tcp://localhost:1234/RemoteCalcServer.soap");

                //Factory
                IMemFactory fact = (IMemFactory)Activator.GetObject(
                                typeof(IMemFactory),
                                "http://localhost:1234/RemoteCalcServer.soap");
                m_calc = fact.GetNewInstanceCalc();
            }
            catch (Exception ex)
            {
                textRes.Text = ex.Message+"\n"+ex.StackTrace;
            }
        }
开发者ID:pepipe,项目名称:ISEL,代码行数:33,代码来源:Form1.cs

示例5: Main

        static void Main(string[] args)
        {
            //string ConfigFile = Process.GetCurrentProcess().MainModule.FileName + ".config";
            //Console.WriteLine("Using config: " + ConfigFile);
            //RemotingConfiguration.Configure(ConfigFile, false);

            var ch = new HttpChannel(30000);
            ChannelServices.RegisterChannel(ch, false);

            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(TextLib.Converter), "TextLibSvc", WellKnownObjectMode.Singleton
                );

            string cmd = "";
            while(true)
            {
                cmd = Console.ReadLine();
                switch(cmd)
                {
                    case "q":
                        Environment.Exit(0);
                        break;
                }
            }
        }
开发者ID:sgqy,项目名称:CoursePractice,代码行数:25,代码来源:Program.cs

示例6: Main

        static void Main()
        {
            Console.WriteLine("SERVIDOR DE LOGICA DE JUEGO\n");

            RemotingConfiguration.RegisterWellKnownClientType(typeof(SokobanURJC.TablaNombres), "http://localhost:1232/TablaNombres.remoto");
            TablaNombres tablaNombres = (TablaNombres)Activator.GetObject(typeof(SokobanURJC.TablaNombres), "http://localhost:1232/TablaNombres.remoto");
            int puertoLogica = tablaNombres.puertoLogica;
            int puertoNiveles = tablaNombres.puertoNiveles;
            String nombreLevel = tablaNombres.nombreLevel;
            String nombreLevelSet = tablaNombres.nombreLevelSet;
            String nombreNiveles = tablaNombres.nombreNiveles;

            Console.WriteLine("Conectando con servidor de niveles\n\npuerto: " + puertoNiveles);
            Console.WriteLine("Estableciendo direccion de servicio de logica:\n\npuerto: " + puertoLogica + "\nnombres de los objetos remotos: " + nombreLevel + ", y " + nombreLevelSet);

            HttpChannel chnlBoard = new HttpChannel(puertoLogica);
            ChannelServices.RegisterChannel(chnlBoard);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(SokobanURJC.Level), nombreLevel, WellKnownObjectMode.Singleton);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(SokobanURJC.LevelSet), nombreLevelSet, WellKnownObjectMode.Singleton);

            RemotingConfiguration.RegisterWellKnownClientType(typeof(SokobanURJC.ColeccionNiveles), "http://localhost:" + puertoNiveles + "/" + nombreNiveles);

            Console.WriteLine("\n\nAtendiendo las peticiones. Pulse Enter para salir.");
            Console.ReadLine();

            ChannelServices.UnregisterChannel(chnlBoard);
        }
开发者ID:javieraguirre,项目名称:Master,代码行数:27,代码来源:ServidorLogica.cs

示例7: Main

        static void Main(string[] args)
        {
            try
            {
                var channel = new HttpChannel();

                ChannelServices.RegisterChannel(channel, false);

                var gumballMachineRemote =
                (IGumballMachineRemote)Activator.GetObject(
                    typeof(IGumballMachineRemote), "http://localhost:9998/GumballMachine");

                var monitor = new GumballMonitor(gumballMachineRemote);

                monitor.printReport();

            }
            catch (Exception e)
            {
                throw new RemoteException(e.Message, e);
            }

            var gumballMachine = new GumballMachine(15, "Madrid");
            var gumballMonitor = new GumballMonitor(gumballMachine);
            gumballMonitor.printReport();

            //for (int i = 0; i < 20; i++)
            //{

            //    gumballMachine.insertQuarter();
            //    gumballMachine.trunCrank();
            //}

            Console.ReadLine();
        }
开发者ID:jhuerta,项目名称:DesignPatterns_Tutorial_HeadFirst,代码行数:35,代码来源:Program.cs

示例8: Run

		public void Run()
		{
			try
			{
				tcp =  new TcpChannel (0);
				http =  new HttpChannel (0);
			
				ChannelServices.RegisterChannel (tcp);
				ChannelServices.RegisterChannel (http);
			
				AppDomain domain = AppDomain.CreateDomain ("testdomain_activation");
				server = (ActivationServer) domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName,"MonoTests.Remoting.ActivationServer");
				
				RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject1), "tcp://localhost:9433");
				RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject2), "http://localhost:9434");
				RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall1), "tcp://localhost:9433/wkoSingleCall1");
				RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton1), "tcp://localhost:9433/wkoSingleton1");
				RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall2), "http://localhost:9434/wkoSingleCall2");
				RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton2), "http://localhost:9434/wkoSingleton2");
			}
			catch (Exception ex)
			{
				Console.WriteLine (ex);
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:25,代码来源:ActivationTests.cs

示例9: Main

        static void Main(string[] args)
        {
            try
            {

                HttpChannel ch = new HttpChannel(0);
                //TcpChannel ch = new TcpChannel(0);
                ChannelServices.RegisterChannel(ch, false);
                ICalc robj = (ICalc)Activator.GetObject(
                                       typeof(ICalc),
                "http://localhost:1234/RemoteCalcServer.soap");

                for (int i = 0; i < 100; i++)
                {

                    Console.WriteLine("valor=" + robj.getValue());
                    System.Threading.Thread.Sleep(1 * 1000);
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }

            Console.ReadLine();
        }
开发者ID:pepipe,项目名称:ISEL,代码行数:27,代码来源:Program.cs

示例10: OnStart

        protected override void OnStart(string[] args)
        {
            HttpChannel channel = new HttpChannel(2222);
            ChannelServices.RegisterChannel(channel, false);

            RemotingServices.Marshal(hello, "kona/hello.soap");
        }
开发者ID:kona4kona,项目名称:KonaRemotingTest,代码行数:7,代码来源:Service1.cs

示例11: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            HttpChannel channel = new HttpChannel();
            ChannelServices.RegisterChannel(channel, false);

            // Registers the remote class. (This could be done with a
            // configuration file instead of a direct call.)
            RemotingConfiguration.RegisterWellKnownClientType(
                Type.GetType("Remote.ServiceClass, remote"),
                "http://localhost:8080/object1uri");

            // Instead of creating a new object, this obtains a reference
            // to the server's single instance of the ServiceClass object.
            ServiceClass object1 = new ServiceClass();

            try
            {
                MessageBox.Show("Suma " + object1.sum(1,3));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception of type: " + ex.ToString() + " occurred.");
                MessageBox.Show("Details: " + ex.Message);
            }
        }
开发者ID:rapsod,项目名称:ProjectManager,代码行数:27,代码来源:MainWindow.xaml.cs

示例12: Main

        public static void Main(string[] args)
        {
            int count = 66;
            string location = "Londres";

            //if (args.Length != 2)
            //{
            //    Console.WriteLine("Gumballs <location> <inventory>");
            //    Environment.Exit(1);
            //}

            //location = args[0];
            //count = int.Parse(args[1]);

            GumballMachine gumballMachine = new GumballMachine(count, location);

            Console.WriteLine("Starting Gumball server...");

            try
            {
                HttpChannel channel = new HttpChannel(9998);
                ChannelServices.RegisterChannel(channel, false);
                RemotingServices.Marshal(gumballMachine, "GumballMachine");

                Console.WriteLine("Press Enter to quit\n\n");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                throw new RemoteException(e.Message, e);
            }
        }
开发者ID:jhuerta,项目名称:DesignPatterns_Tutorial_HeadFirst,代码行数:32,代码来源:Program.cs

示例13: Start

        public static void Start(int port)
        {
            try
            {
                var props = new Hashtable();
                props["name"] = "MyHttpChannel";
                props["port"] = port;

                _channel = new HttpChannel(
                   props,
                   null,
                   new XmlRpcServerFormatterSinkProvider()
                );
                ChannelServices.RegisterChannel(_channel, false);
                RemotingConfiguration.RegisterWellKnownServiceType(
                  typeof(StateNameServer),
                  "statename.rem",
                  WellKnownObjectMode.Singleton);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:25,代码来源:StateNameService.cs

示例14: Login

 public Login()
 {
     InitializeComponent();
     HttpChannel channel = new HttpChannel();
     ChannelServices.RegisterChannel(channel);
     InitializeRemoteServer();
 }
开发者ID:jscr93,项目名称:Chat,代码行数:7,代码来源:Login.xaml.cs

示例15: button3_Click

        private void button3_Click(object sender, EventArgs e)
        {
            HttpChannel d = new HttpChannel();
            try
            {

                ChannelServices.RegisterChannel(d);

                mm = (Wiadomosci)Activator.GetObject(typeof(SimpleConection.Wiadomosci),
                    "http://" + textBox5.Text + ":" + (textBox9.Text.Length == 0 ? "3000" : textBox9.Text) + "/Polaczenie");
                login = textBox7.Text;
                string haslo = maskedTextBox2.Text;
                if (maskedTextBox2.Text == maskedTextBox3.Text)
                    if (mm.rejestracja(login, haslo))
                    {
                        zatw = true;
                        DialogResult = DialogResult.OK;
                        mm.logowanie(login, haslo);
                    }
                    else { MessageBox.Show("login juz istnije"); throw new Exception(); }
                else{ MessageBox.Show("zle hasla"); throw new Exception(); }
                //backgroundWorker1.RunWorkerAsync();
            }
            catch
            {
                //MessageBox.Show("błedny adres lub port serwera");
                ChannelServices.UnregisterChannel(d);
            }
        }
开发者ID:skrzypol,项目名称:Projekt-SR,代码行数:29,代码来源:Logowanie.cs


注:本文中的System.Runtime.Remoting.Channels.Http.HttpChannel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。