Inheritance: System.Runtime.Remoting.Channels.BaseChannelWithProperties, IChannelReceiver, IChannelSender, IChannel, IChannelReceiverHook, ISecurableChannel
コード例 #1
1
        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);
        }
コード例 #2
0
        private void mnuSlaveStart_Click(object sender, EventArgs e)
        {
            try
            {
                // 以指定連接埠的伺服器Channel建立HttpChannel物件
                httpchannel = new System.Runtime.Remoting.Channels.Http.HttpChannel(8080);

                // 註冊Channel服務的Channel通道
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(httpchannel, false);

                // 設定Channel組態
                System.Runtime.Remoting.WellKnownServiceTypeEntry entry =
                    new WellKnownServiceTypeEntry(typeof(RemoteControl), "RemoteSlave", WellKnownObjectMode.SingleCall);

                // 在服務端登錄提供服務之物件
                System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(entry);

                timer1.Enabled = false;
                this.notifyIcon1.ContextMenu = this.contextMenu1;
                this.notifyIcon1.Visible     = true;
                this.Visible = false;

                this.mnuSlaveStart.Enabled = false;
                this.mnuSlaveStop.Enabled  = true;
            }
            catch (Exception ex)
            {
                stop();
                this.mnuSlaveStart.Enabled = true;
                this.mnuSlaveStop.Enabled  = false;
                Console.WriteLine(ex.StackTrace.ToString());
            }
        }
コード例 #3
0
		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);
			}
		}
コード例 #4
0
ファイル: client.cs プロジェクト: mono/gert
		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);
		}
コード例 #5
0
ファイル: Form1.cs プロジェクト: pepipe/ISEL
        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;
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: pepipe/ISEL
        static void Main()
        {
            HttpChannel ch = new HttpChannel(0);
            ChannelServices.RegisterChannel(ch,false);

            Console.WriteLine("vai registar o type Aluno");
            RemotingConfiguration.RegisterActivatedClientType(
                   typeof(Aluno),
                   "http://localhost:1234"
                //ou caso se especifique o nome do serviço
                //"http://localhost:1234/ServerCAO"
               );

            Aluno maria = new Aluno("maria");
            maria.Nome = "maria";
            Console.WriteLine("vai criar Aluno Jose");
            Aluno jose = new Aluno();
            Console.WriteLine("objecto aluno jose é transparente proxy ? {0}",
                                    RemotingServices.IsTransparentProxy(jose));
            Console.WriteLine("criou aluno jose");
            Console.WriteLine(maria.AlunoHello());
            Console.WriteLine(jose.AlunoHello());
            jose.Nome = "José";
            Console.WriteLine(jose.AlunoHello());
            Console.ReadLine();
        }
コード例 #7
0
ファイル: clientForm.cs プロジェクト: Diullei/Storm
 public Form1()
 {
     InitializeComponent();
     //pcName = "somePC";
     HttpChannel c = new HttpChannel();
     ChannelServices.RegisterChannel(c);
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: pepipe/ISEL
        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");

                Console.WriteLine("Vai invokar o metodo getPerson()");
                Person p = robj.getPerson();
                Console.WriteLine("Nome da Pessoa:"+p.nome);
                Console.WriteLine("Resultado da Soma: {0}\n", robj.add(15, 5));
                //Console.ReadLine();
                Console.WriteLine("Resultado da Multiplicação: {0}\n", robj.mult(15, 5));
                Console.WriteLine("valor=" + robj.getValue());
                Console.Write("Introduza um numero inteiro: ");

                string input = Console.ReadLine();
                robj.setValue(int.Parse(input));
                Console.WriteLine("Prima enter");
                Console.ReadLine();
                Console.WriteLine("valor=" + robj.getValue());

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

            Console.ReadLine();
        }
コード例 #9
0
ファイル: Server.cs プロジェクト: pepipe/ISEL
        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();
        }
コード例 #10
0
        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;
            }
        }
コード例 #11
0
        protected override void OnStart(string[] args)
        {
            HttpChannel channel = new HttpChannel(2222);
            ChannelServices.RegisterChannel(channel, false);

            RemotingServices.Marshal(hello, "kona/hello.soap");
        }
コード例 #12
0
ファイル: Login.xaml.cs プロジェクト: jscr93/Chat
 public Login()
 {
     InitializeComponent();
     HttpChannel channel = new HttpChannel();
     ChannelServices.RegisterChannel(channel);
     InitializeRemoteServer();
 }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
ファイル: Logowanie.cs プロジェクト: skrzypol/Projekt-SR
        private void button2_Click(object sender, EventArgs e)
        {
            HttpChannel d = new HttpChannel();
            try
            {

                ChannelServices.RegisterChannel(d);

                mm = (Wiadomosci)Activator.GetObject(typeof(SimpleConection.Wiadomosci),
                    "http://" + textBox3.Text + ":" + (textBox8.Text.Length == 0 ? "3000" : textBox8.Text) + "/Polaczenie");
                login = textBox1.Text;
                string haslo = maskedTextBox1.Text;
                if (mm.logowanie(login, haslo))
                {
                    zatw = true;
                    DialogResult = DialogResult.OK;
                }
                else MessageBox.Show("błedny login lub haslo");
                //backgroundWorker1.RunWorkerAsync();
            }
            catch {
                MessageBox.Show("błedny adres lub port serwera");
                //ChannelServices.UnregisterChannel(d);
            }
        }
コード例 #15
0
ファイル: Logowanie.cs プロジェクト: skrzypol/Projekt-SR
        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);
            }
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: Baptista/SD
        static void Main(string[] args)
        {
            Console.WriteLine("id machine Ex: http://localhost:12344");
            String id = "http://localhost:12344";

            string configfile = "Server2.exe.config";
            //RemotingConfiguration.Configure(configfile, false);

            SoapServerFormatterSinkProvider serverProv = new SoapServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            SoapClientFormatterSinkProvider clientProv = new SoapClientFormatterSinkProvider();
            IDictionary props = new Hashtable();
            props["port"] = 12344;
            HttpChannel ch = new HttpChannel(props, clientProv, serverProv);
            //HttpChannel ch = new HttpChannel(1234);
            ChannelServices.RegisterChannel(ch, false);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerClass2.Server), "RemoteServer2.soap", WellKnownObjectMode.Singleton);

            //HttpChannel ch = new HttpChannel(1);
            //ChannelServices.RegisterChannel(ch, false);

            IManager manager = (IManager)Activator.GetObject(typeof(IManager), "http://localhost:1234/RemoteManager.soap");

            manager.Register(id + "/RemoteServer2.soap");

            Console.WriteLine("Server start");
            Console.ReadLine();

            manager.UnRegister(id + "/RemoteServer2.soap");
        }
コード例 #17
0
        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);
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: pepipe/ISEL
        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();
        }
コード例 #19
0
        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();
        }
コード例 #20
0
        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);
            }
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: sgqy/CoursePractice
        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;
                }
            }
        }
コード例 #22
0
 static void Main(string[] args)
 {
     HttpChannel chnl = new HttpChannel(1234);
     ChannelServices.RegisterChannel(chnl, false);
     RemotingConfiguration.RegisterWellKnownServiceType(typeof(CustomerManager), "CustomerManager.soap", WellKnownObjectMode.Singleton);
     // the server will keep running until keypress.
     Console.ReadLine();
 }
コード例 #23
0
 public static void RegisterHttpChannel(int port)
 {
     //注册通道
     HttpChannel chnl = new HttpChannel(port);
     ChannelServices.RegisterChannel(chnl, false);
     ms_httpchannel = chnl;
     log.Info("Http Service:" + port + " Start!");
 }
コード例 #24
0
ファイル: UserWarehouse.cs プロジェクト: Kmaczek/MDOWebSite
        public static UserWarehouse GetInstance()
        {
            var clientFormatter = new BinaryClientFormatterSinkProvider();
            HttpChannel httpChannel = new HttpChannel(null, clientFormatter, null);
            ChannelServices.RegisterChannel(httpChannel, false);

            return (UserWarehouse)Activator.GetObject(typeof(UserWarehouse), "http://localhost:5000/UserWarehouse");
        }
コード例 #25
0
        /// <summary>
        /// Start this service.
        /// </summary>
        protected override void OnStart(string[] args)
        {
            myChannel = new HttpChannel(4433);

            ChannelServices.RegisterChannel(myChannel);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(SharpPrivacy.SharpPrivacySrv.SharpPrivacy), "SharpPrivacy", WellKnownObjectMode.Singleton);

            EventLog.WriteEntry ("SharpPrivacySrv: Service started successfully");
        }
コード例 #26
0
        static HttpServer()
        {
            HttpChannel channel = new HttpChannel(8100);

            ChannelServices.RegisterChannel(channel);
            //ChannelServices.RegisterChannel(channel, true);

            RemotingConfiguration.RegisterWellKnownServiceType(typeof(IRecordingsManager), "RecordingsManager.soap", WellKnownObjectMode.Singleton);
        }
コード例 #27
0
        public HttpCalculatorClient(string appUrl)
            : base(appUrl)
        {
            channel = new HttpChannel();
            ChannelServices.RegisterChannel(channel, false);

            remoteCalculator = (IRemoteCalculator)Activator.GetObject(
              typeof(IRemoteCalculator),
              appUrl);
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: nemanjazz/iog
        static void Main(string[] args)
        {
            Console.WriteLine("Starting client");

            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();

            IDictionary props = new Hashtable();
            props["port"] = 0;
            props["name"] = "clientChannelName";

            var channel = new HttpChannel(props, clientProv, serverProv);
            ChannelServices.RegisterChannel(channel, false);

            try
            {
                var ctxServer = (IServerContext)RemotingServices.Connect(typeof(IServerContext), "http://localhost:5656" + "/ctxServer");

                var ctxClient = new ClientContext(ctxServer, new Execom.IOG.Storage.MemoryStorageUnsafe<Guid, object>());

                ConsoleKeyInfo pressedKey = new ConsoleKeyInfo();
                do
                {
                    Console.Clear();
                    Console.WriteLine("Press ESC to exit");

                    if (Console.KeyAvailable)
                    {
                        pressedKey = Console.ReadKey();
                    }

                    if (pressedKey.Key != ConsoleKey.Escape)
                    {
                        using (var ws = ctxClient.OpenWorkspace<Execom.IOG.Distributed.Model.IDataModel>(IsolationLevel.Snapshot))
                        {
                            for (int i = 0; i < 1000; i++)
                            {
                                var user = ws.New<IUser>();
                                user.Username = "******";

                                ws.Data.Users.Add(user);
                            }
                            ws.Commit();
                        }
                    }

                }
                while (pressedKey.Key != ConsoleKey.Escape);
            }
            finally
            {
                ChannelServices.UnregisterChannel(channel);
            }
        }
コード例 #29
0
 static void Main(string[] args)
 {
     HttpChannel channel = new HttpChannel();
     ChannelServices.RegisterChannel(channel, false);
     ICustomerManager mgr = (ICustomerManager)Activator.GetObject(typeof(ICustomerManager), "http://localhost:1234/CustomerManager.soap");
     Console.WriteLine("Client.Main(): Reference to CustomerManager acquired");
     Customer cust = mgr.GetCustomer(4711);
     int age = cust.GetAge();
     Console.WriteLine("Client.Main(): Customer {0} {1} is {2} years old.", cust.FirstName, cust.LastName, age);
     Console.ReadLine();
 }
コード例 #30
0
        static RemotingPortalClient()
        {
            Hashtable properties = new Hashtable();
            properties["name"] = "HttpBinary";
            BinaryClientFormatterSinkProvider formatter = new BinaryClientFormatterSinkProvider();
            HttpChannel channel = new HttpChannel(properties, formatter, null);
            ChannelServices.RegisterChannel(channel, EncryptChannel);

            //HttpChannel channel = new HttpChannel();
            //ChannelServices.RegisterChannel(channel, EncryptChannel);
        }
コード例 #31
0
ファイル: Program.cs プロジェクト: pepipe/ISEL
        static void Main(string[] args)
        {
            HttpChannel ch = new HttpChannel();
            ChannelServices.RegisterChannel(ch, false);
            IPix robj = (IPix)Activator.GetObject(
                typeof(IPix),
                "http://localhost:1234/Images.soap");

            DelAdjust del = new DelAdjust(robj.adjustPixel);
            byte[, ,] image = new byte[3, 3, 3] {  { {1,2,3}, { 1, 2, 3}, {1,2,3} },
                                                 { {1,2,3}, { 1, 2, 3}, {1,2,3} },
                                                 { {1,2,3}, { 1, 2, 3}, {1,2,3} } };
            for (int x = 0; x < 3; x++)
                for (int y = 0; y < 3; y++)
                    for (int z = 0; z < 3; z++)
                    {
                        IAsyncResult svasyncres = del.BeginInvoke(0x55, x, y, z,
                                          (IAsyncResult ar) =>  // ou //delegate(IAsyncResult ar)
                                          {
                                              Console.WriteLine("chamada do callback:");
                                              int[] co = (int[])ar.AsyncState;
                                              Console.WriteLine("estado: " + co[0] + "," + co[1]+ ","+co[2]);
                                              AsyncResult ar2 = (AsyncResult)ar;
                                              DelAdjust del2 = (DelAdjust)ar2.AsyncDelegate;
                                              try
                                              {
                                                  image[co[0], co[1], co[2]] = del2.EndInvoke(ar2);
                                                  // x=y=z=3 logo quando for executada a próxima instrução após o primeiro callback
                                                  // ocorrerá uma exception (index out of Bound
                                                  //image[x, y, z] = del2.EndInvoke(ar2);
                                              }
                                              catch (Exception ex)
                                              {
                                                  Console.WriteLine("Ocorreu exception:" + ex.Message);
                                              }
                                          },
                                          new int[] { x, y, z } // passagem de contexto de estado na chamada
                                      );
                    }//for
            Console.WriteLine("Prima enter");
            Console.ReadLine(); // Note que só após todos os callbacks deve premir enter
            for (int x = 0; x < 3; x++)
                for (int y = 0; y < 3; y++)
                {
                    for (int z = 0; z < 3; z++)
                    {
                        Console.Write("["+x+ ","+y+ ","+ z+"]=");
                        Console.WriteLine(" {0:x}", image[x, y, z]);
                    }

                }

            Console.ReadLine();
        }
コード例 #32
0
        private void start()
        {
            frmHost form = new frmHost();

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                string remotehost = form.Host;

                if (remotehost.Length != 0)
                {
                    try
                    {
                        string url = "http://" + remotehost + ":8080/RemoteSlave";

                        // 建立HttpChannel物件
                        httpchannel = new System.Runtime.Remoting.Channels.Http.HttpChannel();

                        // 註冊Channel服務的Channel通道
                        System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(httpchannel, false);

                        // 以指定物件和URL建立Proxy
                        remotecontrol = (RemoteControl)System.Activator.GetObject(typeof(RemoteControl), url);

                        this.connected = true;
                        timer1.Enabled = true;

                        this.FormBorderStyle = FormBorderStyle.None;
                        this.WindowState     = FormWindowState.Maximized;

                        this.mnuView.Visible = true;
                        this.mnuView.Enabled = true;

                        this.mnuMasterStart.Enabled = false;
                        this.mnuMasterStop.Enabled  = true;
                    }
                    catch (Exception ex)
                    {
                        stop();
                        this.mnuMasterStart.Enabled = true;
                        this.mnuMasterStop.Enabled  = false;
                        Console.WriteLine(ex.StackTrace.ToString());
                    }
                }
                else
                {
                    MessageBox.Show("請輸入被控端之IP位址或DNS主機名稱.", "Remote Desktop", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #33
0
        HttpWebRequest CreateRequest(ITransportHeaders requestHeaders)
        {
            string url = this.url;


            //FIXME: requestUri should contain the URL-less URI only when it's a CAO call;
            // at all other times it should be null. On Mono, whenever it should be null, it contains the full
            // URL+URI, so we have a broken mixure of path types and we need to hack around it
            string requestUri = requestHeaders[CommonTransportKeys.RequestUri] as string;
            string objectURI;

            if (requestUri != null && HttpChannel.ParseInternal(requestUri, out objectURI) == null)
            {
                url = HttpChannel.ParseInternal(url, out objectURI);
                if (!url.EndsWith("/"))
                {
                    url = url + "/";
                }
                url = url + requestUri;
            }

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.UserAgent = string.Format("Mozilla/4.0+(compatible; Mono Remoting; Mono {0})",
                                              System.Environment.Version);

            //Only set these if they deviate from the defaults, as some map to
            //properties that throw NotImplementedExceptions
            if (channel.Timeout != -1)
            {
                request.Timeout = channel.Timeout;
            }
            if (channel.AllowAutoRedirect == false)
            {
                request.AllowAutoRedirect = false;
            }
            if (channel.Credentials != null)
            {
                request.Credentials = channel.Credentials;
            }
#if NET_2_0
            else if (channel.UseDefaultCredentials == true)
            {
                request.UseDefaultCredentials = true;
            }
#endif
            else if (channel.Username != null && channel.Username.Length > 0)
            {
                if (channel.Domain != null && channel.Domain.Length > 0)
                {
                    request.Credentials = new NetworkCredential(channel.Username, channel.Password,
                                                                channel.Domain);
                }
                else
                {
                    request.Credentials = new NetworkCredential(channel.Username, channel.Password);
                }
            }

            if (channel.UnsafeAuthenticatedConnectionSharing == true)
            {
                request.UnsafeAuthenticatedConnectionSharing = true;
            }
            if (channel.ConnectionGroupName != null)
            {
                request.ConnectionGroupName = channel.ConnectionGroupName;
            }

            /*
             * FIXME: implement these
             * MachineName
             * ProxyName
             * ProxyPort
             * ProxyUri
             * ServicePrincipalName
             * UseAuthenticatedConnectionSharing
             */

            //build the headers
            request.ContentType = (string)requestHeaders["Content-Type"];

            //BUG: Mono formatters/dispatcher don't set this. Something in the MS stack does.
            string method = (string)requestHeaders["__RequestVerb"];
            if (method == null)
            {
                method = "POST";
            }
            request.Method = method;

            foreach (DictionaryEntry entry in requestHeaders)
            {
                string key = entry.Key.ToString();
                if (key != "__RequestVerb" && key != "Content-Type" && key != CommonTransportKeys.RequestUri)
                {
                    request.Headers.Add(key, entry.Value.ToString());
                }
            }
            return(request);
        }
コード例 #34
0
 private void InternalProcessRequest(HttpContext context)
 {
     try
     {
         HttpRequest request = context.Request;
         if (!bLoadedConfiguration)
         {
             lock (ApplicationConfigurationFile)
             {
                 if (!bLoadedConfiguration)
                 {
                     IisHelper.Initialize();
                     if (RemotingConfiguration.ApplicationName == null)
                     {
                         RemotingConfiguration.ApplicationName = request.ApplicationPath;
                     }
                     string path = request.PhysicalApplicationPath + ApplicationConfigurationFile;
                     if (File.Exists(path))
                     {
                         try
                         {
                             RemotingConfiguration.Configure(path, false);
                         }
                         catch (Exception exception)
                         {
                             s_fatalException = exception;
                             this.WriteException(context, exception);
                             return;
                         }
                     }
                     try
                     {
                         IChannelReceiverHook hook = null;
                         foreach (IChannel channel in ChannelServices.RegisteredChannels)
                         {
                             IChannelReceiverHook hook2 = channel as IChannelReceiverHook;
                             if (((hook2 != null) && (string.Compare(hook2.ChannelScheme, "http", StringComparison.OrdinalIgnoreCase) == 0)) && hook2.WantsToListen)
                             {
                                 hook = hook2;
                                 break;
                             }
                         }
                         if (hook == null)
                         {
                             HttpChannel chnl = new HttpChannel();
                             ChannelServices.RegisterChannel(chnl, false);
                             hook = chnl;
                         }
                         string str2 = null;
                         if (IisHelper.IsSslRequired)
                         {
                             str2 = "https";
                         }
                         else
                         {
                             str2 = "http";
                         }
                         string channelUri = str2 + "://" + CoreChannel.GetMachineIp();
                         int    port       = context.Request.Url.Port;
                         string str4       = string.Concat(new object[] { ":", port, "/", RemotingConfiguration.ApplicationName });
                         channelUri = channelUri + str4;
                         hook.AddHookChannelUri(channelUri);
                         ChannelDataStore channelData = ((IChannelReceiver)hook).ChannelData as ChannelDataStore;
                         if (channelData != null)
                         {
                             channelUri = channelData.ChannelUris[0];
                         }
                         IisHelper.ApplicationUrl = channelUri;
                         ChannelServices.UnregisterChannel(null);
                         s_transportSink = new HttpHandlerTransportSink(hook.ChannelSinkChain);
                     }
                     catch (Exception exception2)
                     {
                         s_fatalException = exception2;
                         this.WriteException(context, exception2);
                         return;
                     }
                     bLoadedConfiguration = true;
                 }
             }
         }
         if (s_fatalException == null)
         {
             if (!this.CanServiceRequest(context))
             {
                 this.WriteException(context, new RemotingException(CoreChannel.GetResourceString("Remoting_ChnlSink_UriNotPublished")));
             }
             else
             {
                 s_transportSink.HandleRequest(context);
             }
         }
         else
         {
             this.WriteException(context, s_fatalException);
         }
     }
     catch (Exception exception3)
     {
         this.WriteException(context, exception3);
     }
 }
コード例 #35
0
        //
        // Internal
        //
        // Transform the ASP+ Request and Response Structures in
        // Channel Structures:
        // ** Request.ServerVariables
        // ** Request.InputStream
        // ** Response.Headers
        //
        // This is needed to reduce the between dependency COR Channels
        // and ASP+
        //

        private void InternalProcessRequest(HttpContext context)
        {
            try
            {
                HttpRequest httpRequest = context.Request;

                // check if have previously loaded configuration
                if (!bLoadedConfiguration)
                {
                    // locking a random static variable, so we can lock the class
                    lock (HttpRemotingHandler.ApplicationConfigurationFile)
                    {
                        if (!bLoadedConfiguration)
                        {
                            // Initialize IIS information
                            IisHelper.Initialize();

                            // set application name
                            if (RemotingConfiguration.ApplicationName == null)
                            {
                                RemotingConfiguration.ApplicationName = httpRequest.ApplicationPath;
                            }

                            String filename = String.Concat(httpRequest.PhysicalApplicationPath,
                                                            ApplicationConfigurationFile);

                            if (File.Exists(filename))
                            {
                                try
                                {
                                    RemotingConfiguration.Configure(filename, false /*enableSecurity*/);
                                }
                                catch (Exception e)
                                {
                                    s_fatalException = e;
                                    WriteException(context, e);
                                    return;
                                }
                            }

                            try
                            {
                                // do a search for a registered channel that wants to listen
                                IChannelReceiverHook httpChannel = null;
                                IChannel[]           channels    = ChannelServices.RegisteredChannels;
                                foreach (IChannel channel in channels)
                                {
                                    IChannelReceiverHook hook = channel as IChannelReceiverHook;
                                    if (hook != null)
                                    {
                                        if (String.Compare(hook.ChannelScheme, "http", StringComparison.OrdinalIgnoreCase) == 0)
                                        {
                                            if (hook.WantsToListen)
                                            {
                                                httpChannel = hook;
                                                break;
                                            }
                                        }
                                    }
                                }

                                if (httpChannel == null)
                                {
                                    // No http channel that was listening found.
                                    // Create a new channel.
                                    HttpChannel newHttpChannel = new HttpChannel();
                                    ChannelServices.RegisterChannel(newHttpChannel, false /*enableSecurity*/);
                                    httpChannel = newHttpChannel;
                                }

                                String scheme = null;
                                if (IisHelper.IsSslRequired)
                                {
                                    scheme = "https";
                                }
                                else
                                {
                                    scheme = "http";
                                }

                                String hookChannelUri =
                                    scheme + "://" + CoreChannel.GetMachineIp();

                                int    port      = context.Request.Url.Port;
                                String restOfUri = ":" + port + "/" + RemotingConfiguration.ApplicationName;
                                hookChannelUri += restOfUri;

                                // add hook uri for this channel
                                httpChannel.AddHookChannelUri(hookChannelUri);

                                // If it uses ChannelDataStore, re-retrieve updated url in case it was updated.
                                ChannelDataStore cds = ((IChannelReceiver)httpChannel).ChannelData as ChannelDataStore;
                                if (cds != null)
                                {
                                    hookChannelUri = cds.ChannelUris[0];
                                }

                                IisHelper.ApplicationUrl = hookChannelUri;

                                // This is a hack to refresh the channel data.
                                //   In V-Next, we will add a ChannelServices.RefreshChannelData() api.
                                ChannelServices.UnregisterChannel(null);

                                s_transportSink = new HttpHandlerTransportSink(httpChannel.ChannelSinkChain);
                            }
                            catch (Exception e)
                            {
                                s_fatalException = e;
                                WriteException(context, e);
                                return;
                            }
                            bLoadedConfiguration = true;
                        }
                    }
                }

                if (s_fatalException == null)
                {
                    if (!CanServiceRequest(context))
                    {
                        WriteException(context, new RemotingException(CoreChannel.GetResourceString("Remoting_ChnlSink_UriNotPublished")));
                    }
                    else
                    {
                        s_transportSink.HandleRequest(context);
                    }
                }
                else
                {
                    WriteException(context, s_fatalException);
                }
            }
            catch (Exception e)
            {
                WriteException(context, e);
            }
        } // InternalProcessRequest
コード例 #36
0
 public string Parse(string url, out string objectURI)
 {
     return(HttpChannel.ParseInternal(url, out objectURI));
 }