Exemple #1
0
        public static void Main(string[] args)
        {
            /*创建通道*/
            //IpcChannel channel = new IpcChannel();
            //HttpChannel channel_http = new HttpChannel();
            TcpChannel channel_tcp = new TcpChannel();

            /*注册通道*/
            ChannelServices.RegisterChannel(channel_tcp, false);
            /*注册通道 的 远程处理类型*/
            //RemotingConfiguration.RegisterWellKnownClientType(typeof(MessageMarshal.TestMessageMarshal), "http://localhost:8226/test");
            /*注册通道 的 远程处理类型*/
            //RemotingConfiguration.RegisterActivatedClientType(typeof(MessageMarshal.TestMessageMarshal), "http://localhost:8226/test");
            //RemotingConfiguration.RegisterActivatedClientType(typeof(MessageMarshal.TestMessageMarshal), "ipc://localhost:8226/test");
            RemotingConfiguration.RegisterActivatedClientType(typeof(MessageMarshal.TestMessageMarshal), "tcp://localhost:8226/test");
            /*创建消息实体*/
            MessageMarshal.TestMessageMarshal TestMessage = new MessageMarshal.TestMessageMarshal();

            while (true)
            {
                TestMessage.SendMessage("DateTime.Now:" + System.DateTime.Now.ToString());
                Console.WriteLine("send message...");
                Thread.Sleep(2000);
            }
        }
Exemple #2
0
        static void Main()
        {
            // Register a channel.
            TcpChannel myChannel = new TcpChannel();

            ChannelServices.RegisterChannel(myChannel);
            RemotingConfiguration.RegisterActivatedClientType(
                typeof(HelloService), "tcp://localhost:8085/");

            // Get the remote object.
            HelloService myService = new HelloService();

            // Get a sponsor for renewal of time.
            ClientSponsor mySponsor = new ClientSponsor();

            // Register the service with sponsor.
            mySponsor.Register(myService);

            // Set renewaltime.
            mySponsor.RenewalTime = TimeSpan.FromMinutes(2);

            // Renew the lease.
            ILease   myLease = (ILease)mySponsor.InitializeLifetimeService();
            TimeSpan myTime  = mySponsor.Renewal(myLease);

            Console.WriteLine("Renewed time in minutes is " + myTime.Minutes.ToString());

            // Call the remote method.
            Console.WriteLine(myService.HelloMethod("World"));

            // Unregister the channel.
            mySponsor.Unregister(myService);
            mySponsor.Close();
        }
Exemple #3
0
        private void RegistrarObjeto(Type type, string url, string urlSpecialEvent, string assemblyName)
        {
            ObjectType ot;

            if (type.IsSubclassOf(typeof(MarshalByRefObject)))
            {
                object[] o = type.GetCustomAttributes(typeof(ObjectType), false);
                if (o.Length > 0)
                {
                    ot = type.GetCustomAttributes(typeof(ObjectType), false)[0] as ObjectType;

                    switch (ot.Type)
                    {
                    //registra o objeto como um Client Activated Object (CAO)
                    case ObjectType.RemotingType.CAO:
                        RemotingConfiguration.RegisterActivatedClientType(type, url + assemblyName);    //CAO
                        break;

                    //registra o objeto como SingleCall ou Singleton
                    case ObjectType.RemotingType.SingleCall:
                    case ObjectType.RemotingType.SingleTon:
                        RemotingConfiguration.RegisterWellKnownClientType(type, url + type.Name.ToString());
                        break;

                    case ObjectType.RemotingType.SingleTonSpecialEvent:
                        RemotingConfiguration.RegisterWellKnownClientType(type, urlSpecialEvent + type.Name);
                        break;
                    }
                }
                else
                {
                    RemotingConfiguration.RegisterActivatedClientType(type, url + assemblyName);//CAO
                }
            }
        }
        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);
            }
        }
        static void Main(string[] args)
        {
            HttpChannel channel = new HttpChannel();

            ChannelServices.RegisterChannel(channel);

            RemotingConfiguration.RegisterActivatedClientType(
                typeof(Server.MyRemoteObject),
                "http://localhost:1234/MyServer");

            Console.WriteLine("Client.Main(): Creating first object");

            Server.MyRemoteObject obj1 = new Server.MyRemoteObject();

            obj1.setValue(42);

            Console.WriteLine("Client.Main(): Creating second object");
            Server.MyRemoteObject obj2 = new Server.MyRemoteObject();
            obj2.setValue(4711);

            Console.WriteLine("Obj1.getValue(): {0}", obj1.getValue());
            Console.WriteLine("Obj2.getValue(): {0}", obj2.getValue());

            Console.ReadLine();
        }
Exemple #6
0
        static void Main(string[] args)
        {
            var type     = (Types)Int32.Parse(args[0]);
            var serverIp = args[1];
            var port     = Int32.Parse(args[2]);

            RemoteClass.RemoteClass remoteObject = null;

            if (type != Types.ClientAO)
            {
                // Server Activated Objects
                remoteObject = (RemoteClass.RemoteClass)Activator.GetObject(
                    typeof(RemoteClass.RemoteClass),
                    string.Format("tcp://{0}:{1}/{2}", serverIp, port.ToString(), APP_NAME));
            }
            else
            {
                // Client Activated Objects
                RemotingConfiguration.RegisterActivatedClientType(
                    typeof(RemoteClass.RemoteClass),
                    string.Format("tcp://{0}:{1}/{2}", serverIp, port.ToString(), APP_NAME));
                remoteObject = new RemoteClass.RemoteClass();
            }

            while (true)
            {
                Console.WriteLine(remoteObject.Ping());
                Console.WriteLine("n call: " + remoteObject.GetCount().ToString());
                Console.ReadLine();
            }
        }
        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);
            }
        }
        private void ConfigureClientComponent(RemotingStrategy client, Type type, ComponentModel model)
        {
            if (client == RemotingStrategy.None)
            {
                return;
            }

            ResetDependencies(model);

            String uri = ConstructClientURI(client, model.Name, model);

            if (client == RemotingStrategy.Singleton || client == RemotingStrategy.SingleCall)
            {
                RemotingConfiguration.RegisterWellKnownClientType(type, uri);

                model.ExtendedProperties.Add("remoting.uri", uri);
                model.CustomComponentActivator = typeof(RemoteActivator);
            }
            else if (client == RemotingStrategy.ClientActivated)
            {
                CheckHasBaseURI();

                RemotingConfiguration.RegisterActivatedClientType(type, baseUri);

                model.ExtendedProperties.Add("remoting.appuri", baseUri);
                model.CustomComponentActivator = typeof(RemoteClientActivatedActivator);
            }
            else if (client == RemotingStrategy.Component)
            {
                model.ExtendedProperties.Add("remoting.remoteregistry", remoteRegistry);
                model.CustomComponentActivator = typeof(RemoteActivatorThroughRegistry);
            }
        }
        static void Main()
        {
            Console.WriteLine("Press return after the server is started");
            Console.ReadLine();

            ChannelServices.RegisterChannel(new IpcChannel(), false);
            ChannelServices.RegisterChannel(new TcpClientChannel(), false);
            //Hello obj = (Hello)Activator.GetObject(
            //                             typeof(Hello), "tcp://localhost:8086/Hi");


            RemotingConfiguration.RegisterActivatedClientType(typeof(Hello), "ipc://myIPCPort/HelloApp");
            // Hello obj = (Hello)Activator.CreateInstance(typeof(Hello), null, new object[] { new UrlAttribute("ipc://myIPCPort") });
            // Hello obj = (Hello)Activator.CreateInstance(typeof(Hello), null, new object[] { new UrlAttribute("tcp://127.0.0.1:8086/HelloApp") });
            Hello obj = new Hello();

            if (obj == null)
            {
                Console.WriteLine("could not locate server");
                return;
            }
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine(obj.Greeting("Stephanie"));
            }
        }
Exemple #10
0
    public static void Main()
    {
        // Report the initial status.
        Console.WriteLine("Starting client.");

        // Register the TCP channel.
        ChannelServices.RegisterChannel(new TcpChannel());

        //<snippet1>
        // Create a url attribute object.
        UrlAttribute attribute =
            new UrlAttribute("tcp://localhost:1234/RemoteApp");

        Console.WriteLine("UrlAttribute value: {0}", attribute.UrlValue);
        //</snippet1>
        object[] activationAttributes = new object[] { attribute };

        // Register the client for the remote object.
        RemotingConfiguration.RegisterActivatedClientType(
            typeof(RemoteObject),
            "tcp://localhost:1234/RemoteApp");

        // Activate the remote object.
        Console.WriteLine("Activating remote object.");
        RemoteObject obj = (RemoteObject)Activator.CreateInstance(
            typeof(RemoteObject), null, activationAttributes);

        // Invoke a method on the remote object.
        Console.WriteLine("Invoking Hello() on remote object.");
        obj.Hello();

        // Inform the user that the program is exiting.
        Console.WriteLine("The client is exiting.");
    }
    static void Main()
    {
        try
        {
            ChannelServices.RegisterChannel(new TcpChannel());
            RemotingConfiguration.RegisterActivatedClientType(
                typeof(MyServerImpl), "tcp://localhost:8085");
            MyServerImpl myObject = new MyServerImpl();
            for (int i = 0; i <= 4; i++)
            {
                Console.WriteLine(myObject.MyMethod("invoke the server method "
                                                    + (i + 1) + " time."));
            }

// <Snippet1>
            // Check whether the 'MyServerImpl' type is registered as
            // a remotely activated client type.
            ActivatedClientTypeEntry myActivatedClientEntry =
                RemotingConfiguration.IsRemotelyActivatedClientType(
                    typeof(MyServerImpl));
            Console.WriteLine("The Object type is "
                              + myActivatedClientEntry.ObjectType);
            Console.WriteLine("The Application Url is "
                              + myActivatedClientEntry.ApplicationUrl);
// </Snippet1>
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }
Exemple #12
0
        private static void ClientActivated()
        {
            Type   t   = typeof(DemoClass2);
            string url = "tcp://127.0.0.1:8501";

            RemotingConfiguration.RegisterActivatedClientType(t, url);
        }
    public static void Main()
    {
        ChannelServices.RegisterChannel(new TcpChannel());

        RemotingConfiguration.RegisterActivatedClientType(typeof(HelloServiceClass),
                                                          "tcp://localhost:8082");

        try
        {
            HelloServiceClass service = new HelloServiceClass();


            // Calls the remote method.
            Console.WriteLine();
            Console.WriteLine("Calling remote object");
            Console.WriteLine(service.HelloMethod("Caveman"));
            Console.WriteLine(service.HelloMethod("Spaceman"));
            Console.WriteLine(service.HelloMethod("Client Man"));
            Console.WriteLine("Finished remote object call");
            Console.WriteLine();
        }
        catch (Exception ex)
        {
            Console.WriteLine("An exception occured: " + ex.Message);
        }
    }
Exemple #14
0
        static void Main(string[] args)
        {
            var serverIp = args[0];

            var port = Int32.Parse(args[1]);

#if !(ClientAO)
            // Server Activated Objects
            var remoteObject = (RemotableObjects.RemoteClass)Activator.GetObject(
                typeof(RemotableObjects.RemoteClass),
                string.Format("tcp://{0}:{1}/{2}", serverIp, PORT.ToString(), APP_NAME));
#else
            // Client Activated Objects
            RemotingConfiguration.RegisterActivatedClientType(
                typeof(RemotableObjects.RemoteClass),
                string.Format("tcp://{0}:{1}/{2}", serverIp, port.ToString(), APP_NAME));
            var remoteObject = new RemotableObjects.RemoteClass();
#endif

            var info = GetInitData();
            if (remoteObject.Init(info) == null)
            {
                return;
            }


            while (true)
            {
                string command = remoteObject.GetCommand();
                if (command == null)
                {
                    break;
                }

                if (command.Length > 0)
                {
                    int iSpace = command.IndexOf(' ');

                    string fileName  = string.Empty;
                    string arguments = string.Empty;

                    if (iSpace == -1)
                    {
                        fileName = command;
                    }
                    else
                    {
                        fileName  = command.Substring(0, iSpace);
                        arguments = command.Substring(iSpace + 1);
                    }

                    Process.Start(fileName, arguments);
                }

                Thread.Sleep(1000);
            }

            remoteObject.Terminate();
        }
        static void Main()
        {
// <Snippet3>
            // Register the channel.
            TcpChannel myChannel = new TcpChannel();

            ChannelServices.RegisterChannel(myChannel);
            RemotingConfiguration.RegisterActivatedClientType(
                typeof(HelloService), "Tcp://localhost:8085");

            TimeSpan myTimeSpan = TimeSpan.FromMinutes(10);

            // Create a remote object.
            HelloService myService = new HelloService();

            ILease myLease;

            myLease = (ILease)RemotingServices.GetLifetimeService(myService);
            if (myLease == null)
            {
                Console.WriteLine("Cannot lease.");
                return;
            }

            Console.WriteLine("Initial lease time is " + myLease.InitialLeaseTime);
            Console.WriteLine("Current lease time is " + myLease.CurrentLeaseTime);
            Console.WriteLine("Renew on call time is " + myLease.RenewOnCallTime);
            Console.WriteLine("Sponsorship timeout is " + myLease.SponsorshipTimeout);
            Console.WriteLine("Current lease state is " + myLease.CurrentState.ToString());
// </Snippet3>
            // Register with a sponser.
            ClientSponsor mySponsor = new ClientSponsor();

            myLease.Register(mySponsor);
            Console.WriteLine("Wait for lease to expire (approx. 15 seconds)...");
            System.Threading.Thread.Sleep(myLease.CurrentLeaseTime);
            Console.WriteLine("Current lease time before renewal is " + myLease.CurrentLeaseTime);

            // Renew the lease time.
            myLease.Renew(myTimeSpan);
            Console.WriteLine("Current lease time after renewal is " + myLease.CurrentLeaseTime);

            // Call the Remote method.
            Console.WriteLine("Remote method output is " + myService.HelloMethod("Microsoft"));

            myLease.Unregister(mySponsor);
            GC.Collect();
            GC.WaitForPendingFinalizers();

            // Register with lease time of 15 minutes.
            myLease.Register(mySponsor, TimeSpan.FromMinutes(15));
            Console.WriteLine("Registered client with lease time of 15 minutes.");
            Console.WriteLine("Current lease time is " + myLease.CurrentLeaseTime);

            // Call the Remote method.
            Console.WriteLine("Remote method output is " + myService.HelloMethod("Microsoft"));
            myLease.Unregister(mySponsor);
        }
Exemple #16
0
    public static void Main()
    {
        // Register TCP Channel.
        ChannelServices.RegisterChannel(new TcpChannel());

        //<snippet2>
        // Create activated client type entry.
        ActivatedClientTypeEntry myActivatedClientTypeEntry =
            new ActivatedClientTypeEntry(typeof(HelloServer),
                                         "tcp://localhost:8082");

        //</snippet2>

        // Register type on client to activate it on the server.
        RemotingConfiguration.RegisterActivatedClientType(
            myActivatedClientTypeEntry);

        // Activate a client activated object type.
        HelloServer myHelloServer = new HelloServer("ParameterString");

        //<snippet3>
        // Print the object type.
        Console.WriteLine(
            "Object type of client activated object: " +
            myActivatedClientTypeEntry.ObjectType.ToString());
        //</snippet3>

        //<snippet4>
        // Print the application URL.
        Console.WriteLine(
            "Application url where the type is activated: " +
            myActivatedClientTypeEntry.ApplicationUrl);
        //</snippet4>

        //<snippet5>
        // Print the string representation of the type entry.
        Console.WriteLine(
            "Type name, assembly name and application URL " +
            "of the remote object: " +
            myActivatedClientTypeEntry.ToString());
        //</snippet5>

        // Print a blank line.
        Console.WriteLine();

        // Check that server was located.
        if (myHelloServer == null)
        {
            Console.WriteLine("Could not locate server");
        }
        else
        {
            Console.WriteLine("Calling remote object");
            Console.WriteLine(myHelloServer.HelloMethod("Bill"));
        }
    }
Exemple #17
0
    internal static void CallShow()
    {
        TcpClientChannel c = new TcpClientChannel();

        ChannelServices.RegisterChannel(c, false);
        RemotingConfiguration.RegisterActivatedClientType(typeof(FormShower), "tcp://localhost:" + PortNumber.ToString());
        FormShower fs = new FormShower();

        fs.Show();
    }
Exemple #18
0
        static public DataAgent GetDataAgent()
        {
            if (!_isInited)
            {
                RemotingConfiguration.RegisterActivatedClientType(typeof(DataAgent), _url);
                _isInited = true;
            }

            return((DataAgent)Activator.GetObject(typeof(DataAgent), _url));
        }
Exemple #19
0
        } // Main

        /// <summary>
        /// Активирует ранее запущенный экземпляр приложения и передает ему параметры командной строки запуска нового экземпляра приложения.
        /// </summary>
        /// <param name="args">Параметры командной строки нового экземпляра, которые будут переданы первому запущенному экземпляру приложения.</param>
        private static void ActivateFirstInstance(string[] args)
        {
            IpcClientChannel channel = new IpcClientChannel();

            ChannelServices.RegisterChannel(channel, false);
            RemotingConfiguration.RegisterActivatedClientType(typeof(Proxy), String.Format("ipc://{0}", IpcPort));
            Proxy proxy = new Proxy();

            proxy.Activate(args);
        } // ActivateFirstInstance
Exemple #20
0
    static void Main(string[] args)
    {
        RemotingConfiguration.RegisterActivatedClientType(typeof(MyServer),
                                                          "tcp://localhost:1234/Test");
        var id = Guid.NewGuid();

        Console.WriteLine("Creating object with id {0}.", id);
        var obj = new MyServer(id);

        obj.DoSomething();
    }
Exemple #21
0
        private void Form1_Load(object sender, EventArgs e)
        {
            RemotingConfiguration.RegisterActivatedClientType(typeof(Jeu), "tcp://localhost:255/nomService");

            proxy = new Jeu();
            ta    = new String[, ] {
                { button11.Text, button12.Text, button13.Text }, { button21.Text, button22.Text, button23.Text }, { button31.Text, button32.Text, button33.Text }
            };
            proxy.initialiser(ta);

            textBox1.Text = proxy.j;
        }
Exemple #22
0
        static void Main(string[] args)
        {
            IDictionary dictionary = new Hashtable();

            dictionary["port"] = 0;

            BinaryClientFormatterSinkProvider clientFormatterSinkProvider;

            clientFormatterSinkProvider = new BinaryClientFormatterSinkProvider();

            BinaryServerFormatterSinkProvider serverFormatterSinkProvider;

            serverFormatterSinkProvider = new BinaryServerFormatterSinkProvider();
            serverFormatterSinkProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            IChannel channel = new TcpChannel(dictionary, clientFormatterSinkProvider, serverFormatterSinkProvider);

            ChannelServices.RegisterChannel(channel, false);

            Type   t   = typeof(CounterService);
            string url = "tcp://127.0.0.1:8501/RemoteLifeTimeMangement";

            RemotingConfiguration.RegisterActivatedClientType(t, url);
            CounterService caoCounter = new CounterService();

            CounterService singletonCounter = Activator.GetObject(t, "tcp://127.0.0.1:8501/RemoteLifeTimeMangement/Counter.rem") as CounterService;


            Thread caothread = new Thread(InvocateCounterService);

            caothread.Name = "cao";

            Thread singletonThread = new Thread(InvocateCounterService);

            singletonThread.Name = "singleton";

            caothread.Start(caoCounter);
            singletonThread.Start(singletonCounter);

            //Thread caoExtend = new Thread(ExtendLifetimeViaLease);
            //Thread singletonExtend = new Thread(ExtendLifetimeViaLease);

            //caoExtend.Start(caoCounter);
            //singletonExtend.Start(singletonCounter);

            //把该Sposnor负值给一个静态变量,这样不会被垃圾回收
            _singletonSponsor = ExtendLifetimeViaSponsor(singletonCounter);
            _caoSponsor       = ExtendLifetimeViaSponsor(caoCounter);

            Console.ReadLine();
        }
Exemple #23
0
		public void RegisterActivatedType()
		{
			TcpChannel chn = null;
			try
			{
				chn = new TcpChannel(1234);
				ChannelServices.RegisterChannel(chn);
				
				// register the CAO
				RemotingConfiguration.RegisterActivatedServiceType(typeof(ActivatedObject));
				
				// get the registered CAO
				ActivatedServiceTypeEntry[] ast = RemotingConfiguration.GetRegisteredActivatedServiceTypes();
				
				bool IsServerRegistered = false;
				foreach(ActivatedServiceTypeEntry aste in ast)
				{
					if(aste.ObjectType == typeof(ActivatedObject))
					{
						IsServerRegistered = true;
						break;
					}
				}
				
				Assert.IsTrue(IsServerRegistered, "#A07");
				
				RemotingConfiguration.RegisterActivatedClientType(typeof(DerivedActivatedObject), "tcp://localhost:1234");
				
				ActivatedClientTypeEntry[] act = RemotingConfiguration.GetRegisteredActivatedClientTypes();
				
				bool IsClientRegistered = false;
				foreach(ActivatedClientTypeEntry acte in act)
				{
					if(acte.ObjectType == typeof(DerivedActivatedObject))
					{
						IsClientRegistered = true;
						break;
					}
				}
				
				Assert.IsTrue(IsClientRegistered);				, "#A08");
				
				// This will send a RemotingException since there is no service named DerivedActivatedObject
				// on the server
				DerivedActivatedObject objDerivedActivated = new DerivedActivatedObject();
			}
Exemple #24
0
        private void SendCommandLineArgs(string[] args)
        {
            try
            {
                IpcClientChannel channel = new IpcClientChannel();
                ChannelServices.RegisterChannel(channel, false);

                RemotingConfiguration.RegisterActivatedClientType(typeof(RemotableObject), "ipc://pvp");

                RemotableObject proxy = new RemotableObject();
                proxy.BringToFront(_appGuid);
                proxy.ProcessArguments(_appGuid, args);
            }
            catch
            { // log it
            }
        }
 static void Main()
 {
     try
     {
         ChannelServices.RegisterChannel(new TcpChannel());
         RemotingConfiguration.RegisterActivatedClientType(typeof(MyServerImpl), "tcp://localhost:8085");
         MyServerImpl myObject = new MyServerImpl();
         for (int i = 0; i <= 4; i++)
         {
             Console.WriteLine(myObject.MyMethod("invoke the server method " + (i + 1) + " time"));
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Exemple #26
0
        static void Main(string[] args)
        {
            HttpChannel channel = new HttpChannel();

            ChannelServices.RegisterChannel(channel);
            RemotingConfiguration.RegisterActivatedClientType(
                typeof(Utils.Catalog),
                "http://localhost:12345/");

            Catalog catalog  = new Catalog();
            int     materie1 = catalog.adaugaMaterie("sd");
            int     materie2 = catalog.adaugaMaterie("asc");
            int     materie3 = catalog.adaugaMaterie("pl");

            int stud1 = catalog.adaugaStudent("dobreanu mircea", "1307b");
            int stud2 = catalog.adaugaStudent("vladimir lenin", "1307b");
            int stud3 = catalog.adaugaStudent("anna pauker", "1307a");

            // Note pt stud 1
            catalog.adaugaNota(1, stud1, materie1);
            catalog.adaugaNota(2, stud1, materie2);
            catalog.adaugaNota(3, stud1, materie3);

            // Note pt stud 2
            catalog.adaugaNota(4, stud2, materie1);
            catalog.adaugaNota(5, stud2, materie2);
            catalog.adaugaNota(6, stud2, materie3);

            // Note pt stud 3
            catalog.adaugaNota(7, stud3, materie1);
            catalog.adaugaNota(8, stud3, materie2);
            catalog.adaugaNota(9, stud3, materie3);

            Console.WriteLine("Notele la ASC");
            foreach (var nota in catalog.returneazaNote(2))
            {
                Console.WriteLine(nota.ToString());
            }

            Console.WriteLine("grupa 1307b");
            foreach (var numeStudent in catalog.returneazaStudenti("1307b"))
            {
                Console.WriteLine(numeStudent);
            }
        }
Exemple #27
0
        public AdpDataSource()
        {
            wcfServiceClient = new ServiceReference1.Service1Client();


            object[] url = { new UrlAttribute("tcp://localhost:9000/CAO") };
            remotingClientActivatedObject = (ClientActivatedObject)Activator.CreateInstance(
                typeof(ClientActivatedObject), null, url);
            if (_isInitialized == false)
            {
                remotingClientActivatedObject = new ClientActivatedObject();

                _isInitialized = true;
            }

            RemotingConfiguration.RegisterActivatedClientType(typeof(ClientActivatedObject), "tcp://localhost:9000/CAO");
            remotingClientActivatedObject = new ClientActivatedObject();
        }
        private void ServiceManagerForm_Load(object sender, EventArgs e)
        {
            try
            {
                ChannelServices.RegisterChannel(channel, false);
                RemotingConfiguration.RegisterActivatedClientType(typeof(ServiceManager), "ipc://BitAdminChannel/WindowsServices");

                listView1.Select();
                LoadService();

                timer1.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                LogHelper.SaveLog(ex);
            }
        }
Exemple #29
0
    public static void Main()
    {
        ChannelServices.RegisterChannel(new HttpChannel(0));
        RemotingConfiguration.RegisterActivatedClientType(typeof(ClientActivatedType), "http://localhost:8080");

        ClientActivatedType CAObject = new ClientActivatedType();

        ILease          serverLease = (ILease)RemotingServices.GetLifetimeService(CAObject);
        MyClientSponsor sponsor     = new MyClientSponsor();

        serverLease.Register(sponsor);

        // Call same method on the object
        Console.WriteLine("Client-activated object: " + CAObject.RemoteMethod("Bob"));

        Console.WriteLine("Press Enter to end the client application domain.");
        Console.ReadLine();
    }
Exemple #30
0
    public static void Main()
    {
        GenericIdentity  ident = new GenericIdentity("Bob");
        GenericPrincipal prpal = new GenericPrincipal(ident,
                                                      new string[] { "Level1" });
        LogicalCallContextData data = new LogicalCallContextData(prpal);

        //Enter data into the CallContext
        CallContext.SetData("test data", data);


        Console.WriteLine(data.numOfAccesses);

        ChannelServices.RegisterChannel(new TcpChannel());

        RemotingConfiguration.RegisterActivatedClientType(typeof(HelloServiceClass),
                                                          "tcp://localhost:8082");

        HelloServiceClass service = new HelloServiceClass();

        if (service == null)
        {
            Console.WriteLine("Could not locate server.");
            return;
        }


        // call remote method
        Console.WriteLine();
        Console.WriteLine("Calling remote object");
        Console.WriteLine(service.HelloMethod("Caveman"));
        Console.WriteLine(service.HelloMethod("Spaceman"));
        Console.WriteLine(service.HelloMethod("Bob"));
        Console.WriteLine("Finished remote object call");
        Console.WriteLine();

        //Extract the returned data from the call context
        LogicalCallContextData returnedData =
            (LogicalCallContextData)CallContext.GetData("test data");

        Console.WriteLine(data.numOfAccesses);
        Console.WriteLine(returnedData.numOfAccesses);
    }