예제 #1
0
        public void Run()
        {
            try
            {
                Hashtable tcpOptions = new Hashtable();
                tcpOptions ["port"]   = 0;
                tcpOptions ["bindTo"] = "127.0.0.1";
                tcp = new TcpChannel(tcpOptions, null, null);

                Hashtable options = new Hashtable();
                options ["timeout"] = 10000;                 // 10s
                http = new HttpClientChannel(options, null);

                ChannelServices.RegisterChannel(tcp);
                ChannelServices.RegisterChannel(http);

                AppDomain domain = BaseCallTest.CreateDomain("testdomain_activation");
                server = (ActivationServer)domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName, "MonoTests.Remoting.ActivationServer");

                var tcpUrlPrefix  = $"tcp://127.0.0.1:{server.TcpPort}";
                var httpUrlPrefix = $"http://127.0.0.1:{server.HttpPort}";
                RemotingConfiguration.RegisterActivatedClientType(typeof(CaObject1), tcpUrlPrefix);
                RemotingConfiguration.RegisterActivatedClientType(typeof(CaObject2), httpUrlPrefix);
                RemotingConfiguration.RegisterWellKnownClientType(typeof(WkObjectSinglecall1), tcpUrlPrefix + "/wkoSingleCall1");
                RemotingConfiguration.RegisterWellKnownClientType(typeof(WkObjectSingleton1), tcpUrlPrefix + "/wkoSingleton1");
                RemotingConfiguration.RegisterWellKnownClientType(typeof(WkObjectSinglecall2), httpUrlPrefix + "/wkoSingleCall2");
                RemotingConfiguration.RegisterWellKnownClientType(typeof(WkObjectSingleton2), httpUrlPrefix + "/wkoSingleton2");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
예제 #2
0
    public static void Main(string[] args)
    {
        // Create the channel.
        HttpClientChannel clientChannel = null;
        string            overload      = args[0];

        if (overload == "1")
        {
            clientChannel = Ctor1();
        }
        else if (overload == "2")
        {
            clientChannel = Ctor2();
        }
        else
        {
            throw new Exception("Argument " + args[0] + "was invalid.");
        }

        // Register the channel and the client.
        Register(clientChannel);

        // Create an instance of the remote object.
        RemoteObject service = new RemoteObject();

        // Invoke a method on the remote object.
        InvokeRemoteObject(service);
    }
        public override MConnector Connect(String url, System.Collections.Specialized.NameValueCollection properties)
        {
            String[] parts = StripUrl(url);

            String formatter = parts[2];
            String objectUri = parts[3];
            String objectUrl = null;

            HttpClientChannel channel = new HttpClientChannel();

            try
            {
                ChannelServices.RegisterChannel(channel);
            }
            catch (RemotingException)
            {
                // Already registered
            }

            objectUrl = String.Format("{0}://{1}:{2}/{3}",
                                      "http", GetHost(properties), GetPort(properties), objectUri);

            object ret = RemotingServices.Connect(typeof(MServer), objectUrl, null);

            return(new MConnector((MServer)ret, channel));
        }
        public void Run()
        {
            try
            {
                tcp = new TcpChannel(0);

                Hashtable options = new Hashtable();
                options ["timeout"] = 10000; // 10s
                http = new HttpClientChannel(options, null);

                ChannelServices.RegisterChannel(tcp);
                ChannelServices.RegisterChannel(http);

                AppDomain domain = BaseCallTest.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);
            }
        }
예제 #5
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup

            // server registration using http
            IDictionary properties = new Hashtable();

            properties["machineName"] = Properties.Settings.Default.hMailServerWebAdminMachineName;
            HttpServerChannel channel = new HttpServerChannel(properties, null);

            ChannelServices.RegisterChannel(channel, false);

            LifetimeServices.LeaseTime       = TimeSpan.FromMinutes(10);
            LifetimeServices.RenewOnCallTime = TimeSpan.FromMinutes(15);

            RemotingConfiguration.RegisterWellKnownServiceType(new WellKnownServiceTypeEntry(
                                                                   typeof(hMailServerNetRemote.ClassFactory),
                                                                   "Remote.soap",
                                                                   WellKnownObjectMode.SingleCall
                                                                   ));

            // client registration (for calling a server) using http
            BinaryClientFormatterSinkProvider clnt = new BinaryClientFormatterSinkProvider();
            HttpClientChannel client = new HttpClientChannel((IDictionary)null, clnt);

            ChannelServices.RegisterChannel(client, false);
        }
예제 #6
0
파일: Form1.cs 프로젝트: banyaai/PUS
        private void button1_Click_1(object sender, EventArgs e)
        {
            string adres = textBox1.Text;

            adres = "http://" + adres;
            int port = Convert.ToInt32(textBox2.Text);
            HttpClientChannel kanal = null;

            try
            {
                kanal = new HttpClientChannel();
                ChannelServices.RegisterChannel(kanal, false);
                ZdalnyObiekt obiekt = (ZdalnyObiekt)Activator.GetObject(typeof(ZdalnyObiekt), adres + ":" + port.ToString() +
                                                                        "/NazwaUslugiProjektu");
                listBox1.Items.Add(obiekt.ZwrocTekst(textBox3.Text, textBox4.Text));
                ChannelServices.UnregisterChannel(kanal);
                listBox1.Items.Add("polaczenie zostalo zakonczone");
            }
            catch (Exception ext)
            {
                MessageBox.Show(ext.Message, "blad");
                listBox1.Items.Add("blad polaczenia");
                ChannelServices.UnregisterChannel(kanal);
            }
        }
예제 #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            string address = textBox1.Text;

            if (!address.StartsWith("http://"))
            {
                address = "http://" + textBox1.Text;
            }
            int port = (int)numericUpDown1.Value;
            HttpClientChannel channel = null;

            try
            {
                channel = new HttpClientChannel();
                ChannelServices.RegisterChannel(channel, false);
                RemotingObject remotingObject = (RemotingObject)Activator.GetObject(typeof(RemotingObject), address + ":" + port.ToString() + "/Remoting");
                listBox1.Items.Add("Połączenie: " + address + ":" + port.ToString() + "/Remoting");
                listBox1.Items.Add(remotingObject.Test());
                ChannelServices.UnregisterChannel(channel);
                listBox1.Items.Add("Połączenie zakończone");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Błąd");
                listBox1.Items.Add("Połączenie przerwane");
                ChannelServices.UnregisterChannel(channel);
            }
        }
예제 #8
0
        static void Main(string[] args)
        {
            CookieContainer cookieContainer = new CookieContainer();

            using (HttpClient client = new HttpClient("http://localhost:44857/")) {
                HttpClientChannel clientChannel = new HttpClientChannel();
                clientChannel.CookieContainer = cookieContainer;
                client.Channel = clientChannel;
                HttpContent loginData = new FormUrlEncodedContent(
                    new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("Username", "foo"),
                    new KeyValuePair <string, string>("Password", "bar")
                }
                    );
                client.Post("login", loginData);
            }

            string result = string.Empty;

            using (HttpClient client = new HttpClient("http://localhost:44857/contact/")) {
                HttpClientChannel clientChannel = new HttpClientChannel();
                clientChannel.CookieContainer = cookieContainer;
                client.Channel = clientChannel;
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = client.Get("1");
                result = response.Content.ReadAsString();
            }

            JavaScriptSerializer jsonDeserializer = new JavaScriptSerializer();
            ContactDto           contact          = jsonDeserializer.Deserialize <ContactDto>(result);

            Console.WriteLine(contact.Name);
            Console.ReadLine();
        }
예제 #9
0
        public static void PrepareGetService()
        {
            var clientChannel = new HttpClientChannel();

            ChannelServices.RegisterChannel(clientChannel, false);

            RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
        }
예제 #10
0
        public ConfigurationWizard()
        {
            InitializeComponent();
            pastPanels = new ArrayList();
            pastPanels.Add(mainPanel);
            currentPanel = mainPanel;
            HttpClientChannel chan = new HttpClientChannel();

            ChannelServices.RegisterChannel(chan, false);
        }
예제 #11
0
        //setup HTTP client channel
        public void InitializeClientChannel(string name, bool enableSecurity)
        {
            RemotingUtils.RemoveChannel(name);

            var sinkProvider = new BinaryClientFormatterSinkProvider();

            var channel = new HttpClientChannel(name, sinkProvider);

            ChannelServices.RegisterChannel(channel, enableSecurity);
        }
    public static void Main(string[] args)
    {
        // Create the channel.
        HttpClientChannel clientChannel = new HttpClientChannel();

        // Register the channel.
        ChannelServices.RegisterChannel(clientChannel);

        // Register as client for remote object.
        WellKnownClientTypeEntry remoteType =
            new WellKnownClientTypeEntry(typeof(RemoteObject),
                                         "http://localhost:9090/RemoteObject.rem");

        RemotingConfiguration.RegisterWellKnownClientType(remoteType);

        // Create a message sink.
        string objectUri;

        System.Runtime.Remoting.Messaging.IMessageSink messageSink =
            clientChannel.CreateMessageSink(
                "http://localhost:9090/RemoteObject.rem",
                null, out objectUri);
        Console.WriteLine(
            "The URI of the message sink is {0}.",
            objectUri);
        if (messageSink != null)
        {
            Console.WriteLine("The type of the message sink is {0}.",
                              messageSink.GetType().ToString());
        }

        // Display the channel's properties using Keys and Item.
        foreach (string key in clientChannel.Keys)
        {
            Console.WriteLine(
                "clientChannel[{0}] = <{1}>",
                key, clientChannel[key]);
        }

        // Parse the channel's URI.
        string objectUrl  = "http://localhost:9090/RemoteObject.rem";
        string channelUri = clientChannel.Parse(objectUrl, out objectUri);

        Console.WriteLine("The object URL is {0}.", objectUrl);
        Console.WriteLine("The object URI is {0}.", objectUri);
        Console.WriteLine("The channel URI is {0}.", channelUri);

        // Create an instance of the remote object.
        RemoteObject service = new RemoteObject();

        // Invoke a method on the remote object.
        Console.WriteLine("The client is invoking the remote object.");
        Console.WriteLine("The remote object has been called {0} times.",
                          service.GetCount());
    }
예제 #13
0
파일: Client.cs 프로젝트: mergun/practises
        private bool Connect()
        {
            HttpClientChannel chan = new HttpClientChannel();

            ChannelServices.RegisterChannel(chan, false);

            Console.Error.WriteLine("Connecting to PractiSES server ({0})...", host);

            server = (IServer)Activator.GetObject(typeof(IServer), "http://" + host + "/PractiSES");

            return(true);
        }
예제 #14
0
        public RestClient(string endpoint, X509Certificate2 certificate, IEnumerable <Observer> observers = null,
                          CancellationToken token = default)
        {
            sendChannel = ChannelFactory.Create(endpoint, certificate) as HttpClientChannel;

            if (observers != null)
            {
                receiveChannel = ChannelFactory.Create(endpoint, certificate, observers, token);

                Task receiveTask = receiveChannel.ReceiveAsync();
                Task.WhenAll(receiveTask);
            }
        }
예제 #15
0
    static void Register(HttpClientChannel channel)
    {
        // Register the channel.
        ChannelServices.RegisterChannel(channel);

        // Register as client for remote object.
        WellKnownClientTypeEntry remoteType =
            new WellKnownClientTypeEntry(
                typeof(RemoteObject),
                "http://localhost:9090/RemoteObject.rem");

        RemotingConfiguration.RegisterWellKnownClientType(remoteType);
    }
예제 #16
0
    private static HttpClientChannel Ctor2()
    {
        //<snippet22>
        // Create a client channel.
        string name = "RemotingClient";
        IClientChannelSinkProvider sinkProvider  = null;
        HttpClientChannel          clientChannel = new HttpClientChannel(name,
                                                                         sinkProvider);

        //</snippet22>

        return(clientChannel);
    }
예제 #17
0
        public MainWindow()
        {
            InitializeComponent();
            gridLogin.Visibility = Visibility.Visible;
            ClearAll();
            gridClientPanel.Visibility = Visibility.Hidden;

            HttpClientChannel channel = new HttpClientChannel();

            ChannelServices.RegisterChannel(channel, false);
            RemotingConfiguration.RegisterWellKnownClientType(typeof(BankLogic), "http://localhost:12345/Bank");
            bank = new BankLogic();
        }
예제 #18
0
파일: Client.cs 프로젝트: mono/gert
	static void Main ()
	{
		HttpClientChannel channel = new HttpClientChannel ();
#if NET_2_0
		ChannelServices.RegisterChannel (channel, false);
#else
		ChannelServices.RegisterChannel (channel);
#endif

		IRemoteInterfaceFactory factory = (IRemoteInterfaceFactory)
			Activator.GetObject (typeof (IRemoteInterfaceFactory),
			"http://localhost:8000/RemoteInterfaceFactory.soap");
		factory.Create ();
	}
예제 #19
0
파일: client.cs 프로젝트: mono/gert
	static void Main ()
	{
		SoapClientFormatterSinkProvider ccsp = new SoapClientFormatterSinkProvider ();
		HttpClientChannel channel = new HttpClientChannel ((IDictionary) null, ccsp);
#if NET_2_0
		ChannelServices.RegisterChannel (channel, false);
#else
		ChannelServices.RegisterChannel (channel);
#endif
		IServer server = (IServer) Activator.GetObject (typeof (IServer), "http://127.0.0.1:8080/Server.rem");
		ISession session = server.LogOn ("Test");
		SessionContext ctx = (SessionContext) CallContext.GetData ("session_ctx");
		Assert.AreSame (session, ctx.Session, "#1");
		Assert.AreEqual ("Session here", session.GetName (), "#2");
	}
예제 #20
0
    private static HttpClientChannel Ctor1()
    {
        //<snippet21>
        // Create a client channel.
        System.Collections.Hashtable properties =
            new System.Collections.Hashtable();
        properties["port"] = 9090;
        IClientChannelSinkProvider sinkProvider  = null;
        HttpClientChannel          clientChannel = new HttpClientChannel(
            properties, sinkProvider);

        //</snippet21>

        return(clientChannel);
    }
    public static void Main()
    {
        try
        {
// <Snippet5>
            // Creating the 'IDictionary' to set the server object properties.
            IDictionary myDictionary = new Hashtable();
            myDictionary["name"]     = "HttpClientChannel";
            myDictionary["priority"] = 2;
            // Set the properties along with the constructor.
            HttpClientChannel myHttpClientChannel =
                new HttpClientChannel(myDictionary, new BinaryClientFormatterSinkProvider());
            // Register the server channel.
            ChannelServices.RegisterChannel(myHttpClientChannel);
            MyHelloServer myHelloServer1 = (MyHelloServer)Activator.GetObject(
                typeof(MyHelloServer), "http://localhost:8085/SayHello");
            if (myHelloServer1 == null)
            {
                System.Console.WriteLine("Could not locate server");
            }
            else
            {
                Console.WriteLine(myHelloServer1.myHelloMethod("Client"));
                // Get the name of the channel.
                Console.WriteLine("Channel Name :" + myHttpClientChannel.ChannelName);
                // Get the channel priority.
                Console.WriteLine("ChannelPriority :" + myHttpClientChannel.ChannelPriority.ToString());
                string myString, myObjectURI1;
                Console.WriteLine("Parse :" +
                                  myHttpClientChannel.Parse("http://localhost:8085/SayHello", out myString) + myString);
                // Get the key count.
                System.Console.WriteLine("Keys.Count : " + myHttpClientChannel.Keys.Count);
                // Get the channel message sink that delivers message to the specified url.
                IMessageSink myIMessageSink =
                    myHttpClientChannel.CreateMessageSink("http://localhost:8085/NewEndPoint",
                                                          null, out myObjectURI1);
                Console.WriteLine("The channel message sink that delivers the messages to the URL is : "
                                  + myIMessageSink.ToString());
                Console.WriteLine("URI of the new channel message sink is: " + myObjectURI1);
            }
// </Snippet5>
        }
        catch (Exception ex)
        {
            Console.WriteLine("The following exception is raised on client side :" + ex.Message);
        }
    }
예제 #22
0
        [Category("NotWorking")] // disabled as it got not working by NUnit upgrade to 2.4.8
        public void MultiClientConnection()
        {
            int num_clients = 20;

            Hashtable options = new Hashtable();

            options ["timeout"] = 10000;                   // 10s
            options ["name"]    = "MultiClientConnection"; // 10s
            HttpClientChannel clientChannel = new HttpClientChannel(options, null);

            ChannelServices.RegisterChannel(clientChannel);
            try
            {
                WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(
                    typeof(RemoteObject), "http://127.0.0.1:9090/RemoteObject.rem");
                RemotingConfiguration.RegisterWellKnownClientType(remoteType);

                // start a bunch of clients...
                Thread [] clients = new Thread [num_clients];
                retvals = new bool [num_clients];

                lock (mutex)
                {
                    for (int i = 0; i < num_clients; i++)
                    {
                        clients[i] = new Thread(MultiClientStart);
                        clients[i].Start();
                        retvals[i] = false;
                    }
                }

                // wait for all clients to finish...
                for (int i = 0; i < num_clients; i++)
                {
                    clients[i].Join();
                }

                for (int i = 0; i < num_clients; i++)
                {
                    Assert.IsTrue(retvals[i], "RemoteObject.Incrememnt() didn't return a value of " + i);
                }
            }
            finally
            {
                ChannelServices.UnregisterChannel(clientChannel);
            }
        }
예제 #23
0
        static void Main(string[] args)
        {
            HttpClientChannel httpChannel = new HttpClientChannel();

            ChannelServices.RegisterChannel(httpChannel);
            WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(Library.Catalog), "http://localhost:12345/Catalog.rem");

            RemotingConfiguration.RegisterWellKnownClientType(remoteType);


            Catalog catalog     = new Catalog();
            int     id_materie1 = catalog.adaugaMaterie("sd");
            int     id_materie2 = catalog.adaugaMaterie("asc");
            int     id_materie3 = catalog.adaugaMaterie("pl");

            int id_student1 = catalog.adaugaStudent("mircea dobreanu", "1307b");
            int id_student2 = catalog.adaugaStudent("andrei covas", "1307b");
            int id_student3 = catalog.adaugaStudent("anonimus", "1310a");


            catalog.adaugaNota(3, id_student1, id_materie1);
            catalog.adaugaNota(2, id_student1, id_materie2);
            catalog.adaugaNota(1, id_student1, id_materie3);

            catalog.adaugaNota(10, id_student2, id_materie1);
            catalog.adaugaNota(9, id_student2, id_materie2);
            catalog.adaugaNota(8, id_student2, id_materie3);

            catalog.adaugaNota(5, id_student3, id_materie1);
            catalog.adaugaNota(4, id_student3, id_materie2);
            catalog.adaugaNota(3, id_student3, id_materie3);

            Console.WriteLine("grupa 1307b");
            foreach (string student in catalog.returneazaStudenti("1307b"))
            {
                Console.WriteLine(student);
            }

            foreach (Nota nota in catalog.returneazaNote(id_materie2))
            {
                Console.WriteLine(nota.ToString());
            }

            //RemotingConfiguration.Configure("Client.exe.config");
            //RemotingConfiguration.RegisterWellKnownClientType(typeof(Library.Catalog), "http://localhost:12345/Catalog.rem");
        }
예제 #24
0
        static void Main(string[] args)
        {
            HttpClientChannel channel = new HttpClientChannel();

            ChannelServices.RegisterChannel(channel);
            RemoteObj obj = (RemoteObj)Activator.GetObject(typeof(RemoteObj), "http://localhost:5555/tienhai");

            if (obj.checkLogin("abc", "123"))
            {
                Console.WriteLine("OK");
            }
            else
            {
                Console.WriteLine("Bay r");
            }
            Console.ReadLine();
        }
예제 #25
0
        /// <summary>
        /// 监听Http信道
        /// </summary>
        /// <param name="port">端口</param>
        /// <param name="channelName">信道名称</param>
        public void ListenHttpChannel(string channelName, FormatterSinkProviderType fspt = FormatterSinkProviderType.Binary)
        {
            IDictionary props = new Hashtable();

            props["port"] = 0;
            props["name"] = channelName;
            IClientChannelSinkProvider cckp = sinkBinaryProvider;

            if (fspt == FormatterSinkProviderType.Soap)
            {
                cckp = sinkSoapProvider;
            }
            HttpClientChannel srvChannel = new HttpClientChannel(props, cckp);

            ChannelServices.RegisterChannel(srvChannel, false);
            httpChannels.Add(channelName);
        }
예제 #26
0
        public void Start()
        {
            StartCalled = true;

            string AppPath = ACA.LabelX.GlobalDataStore.AppPath; // System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            string RemotingConfigFilePath = AppPath + @"\ACALabelXClient.config.xml";

            if (!File.Exists(RemotingConfigFilePath))
            {
                throw new LabelXClientEngineException(string.Format("Remoting configuration file doesn't exist: {0}", RemotingConfigFilePath));
            }

            string Protocol;
            string Address;
            string Port;
            string Uri;

            Toolbox.Toolbox toolbox = new Toolbox.Toolbox();
            toolbox.GetRemotingClientConfiguraton(RemotingConfigFilePath, out Protocol, out Address, out Port, out Uri);

            Hashtable myTable = new Hashtable();

            switch (Protocol.ToLower())
            {
            case "http":
                myTable["name"] = "servercon";
                HttpClientChannel theHttp = new HttpClientChannel(myTable, null);
                ChannelServices.RegisterChannel(theHttp, false);
                break;

            case "tcp":
                myTable["name"] = "servercon";
                TcpClientChannel theTcp = new TcpClientChannel(myTable, null);
                ChannelServices.RegisterChannel(theTcp, false);
                break;

            default:
                throw new LabelXClientEngineException(string.Format("Cannot obtain the correct protocol from the Remoting configuration file: {0}\r\nProtocol found: {1}\r\nShould be: http, or tcp", RemotingConfigFilePath, Protocol));
            }

            ServerURL = string.Format("{0}://{1}:{2}/{3}", Protocol, Address, Port, Uri);

            PrintGroups = new List <LabelX.Toolbox.PrintGroupItem>();
            toolbox.GetGeneralClientConfiguraton(AppPath + @"\ACALabelXClient.config.xml", out PrintJobsRootFolder, out LabelDefinitionsRootFolder, out PaperDefinitionsRootFolder, out SettingsRootFolder, out PicturesRootFolder, out UpdateRootFolder, out MachineName, out PollFrequency, ref PrintGroups);
        }
예제 #27
0
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         button4.Enabled = false;
         Application.DoEvents();
         _server = null;
         ChannelServices.UnregisterChannel(_cnl);
         _cnl            = null;
         button3.Enabled = true;
     }
     catch (Exception ex)
     {
         CommonLib.HandleException(ex);
         button3.Enabled = false;
         button4.Enabled = true;
     }
 }
예제 #28
0
        public void TestReceiveInvalidResponse(string response)
        {
            var innerChannel = new TestClientChannel();
            var httpChannel  = new HttpClientChannel(innerChannel, logger);
            int i            = 0;

            httpChannel.ResponseReceived += delegate(object sender, DataEventArgs e)
            {
                ++i;
                Assert.IsNotType <HttpData>(e.Data);
            };
            Assert.Equal(0, i);
            IDataStream stream = new ByteArray(ASCIIEncoding.ASCII.GetBytes(response));

            innerChannel.Receive(stream);
            innerChannel.Close();
            Assert.Equal(1, i);
        }
예제 #29
0
        static void Main(string[] args)
        {
            HttpClientChannel serverChannel = new HttpClientChannel();

            ChannelServices.RegisterChannel(serverChannel, false);

            for (int i = 0; i < 5; i++)
            {
                ICountingService countingService =
                    (ICountingService)Activator.GetObject(typeof(ICountingService),
                                                          "http://localhost:8234/CountingService.rem");

                int newValue = countingService.Increment();
                Console.WriteLine("Value is " + newValue);
            }

            Console.WriteLine("Press enter to exit.");
            Console.ReadLine();
        }
예제 #30
0
        static void Main(string[] args)
        {
            Console.WriteLine("启动IPC客户端,回车生成远程代理");

            //IDictionary props = new Hashtable();
            //props["name"] = "IpcClient";
            //BinaryClientFormatterSinkProvider bProvider = new BinaryClientFormatterSinkProvider();
            //IpcClientChannel channel = new IpcClientChannel(props, bProvider);
            //ChannelServices.RegisterChannel(channel, false);

            //FileService fs = Activator.GetObject(typeof(FileService), "ipc://TestChannel/FileService") as FileService;
            //string content = fs.GetFileName();
            //Console.WriteLine(content);

            //IDictionary props = new Hashtable();
            //props["name"] = "IpcClient";
            //BinaryClientFormatterSinkProvider bProvider = new BinaryClientFormatterSinkProvider();
            //IpcClientChannel channel = new IpcClientChannel(props, bProvider);
            //ChannelServices.RegisterChannel(channel, false);

            //IDBMgr sss = Activator.GetObject(typeof(IDBMgr), "ipc://dbChannel/DBMgr") as IDBMgr;

            //List<MServiceInfo> s = sss.GetServices();
            //string content = fs.GetFileName();

            Hashtable props = new Hashtable();

            props["name"] = "httpClient";
            BinaryClientFormatterSinkProvider client = new BinaryClientFormatterSinkProvider();
            HttpClientChannel http = new HttpClientChannel(props, client);

            ChannelServices.RegisterChannel(http, false);
            IFileMgr fileMgr = Activator.GetObject(typeof(IFileMgr), "http://localhost:31000/FileMgr") as IFileMgr;
            string   test    = fileMgr.Test();

            for (int i = 0; i < ChannelServices.RegisteredChannels.Length; i++)
            {
                (ChannelServices.RegisteredChannels[i] as HttpChannel).StopListening(null);
                ChannelServices.UnregisterChannel(ChannelServices.RegisteredChannels[i]);
            }

            Console.Read();
        }
예제 #31
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Creamos el canal para el cliente
            HttpClientChannel channel = new HttpClientChannel();

            // Registramos el canal
            ChannelServices.RegisterChannel(channel, false);

            // Registramos el objeto remoto del servidor
            WellKnownClientTypeEntry remote = new WellKnownClientTypeEntry(typeof(objeto_op.operaciones), "http://localhost:9090/Operaciones");

            RemotingConfiguration.RegisterWellKnownClientType(remote);

            // Ya podemos arrancar la aplicacion
            Application.Run(new Form1());
        }
예제 #32
0
        private RemotingConnection(RemotingProtocol remProt,
                                   string url, IDictionary propBag)
        {
            switch (remProt)
            {
            case (RemotingProtocol.Tcp):
                tcpCh = new TcpClientChannel(propBag, null);
                ChannelServices.RegisterChannel(tcpCh, false);
                break;

            case (RemotingProtocol.Http):
                httpCh = new HttpClientChannel(propBag, null);
                ChannelServices.RegisterChannel(httpCh, false);
                break;

            default: break;
            }
            Service = (T)Activator.GetObject(typeof(T), url);
        }