Esempio n. 1
0
        static void Main(string[] args)
        {
            TcpChannel channel = new TcpChannel(8086);

            ChannelServices.RegisterChannel(channel, true);

            //Pre-made object
            //duvida: como é que defino a activação do objecto remoto usando o RemotingServices.Marchal
            MyRemoteObject mo = new MyRemoteObject();

            RemotingServices.Marshal(
                mo,
                "MyRemoteObjectName",
                typeof(MyRemoteObject)
                );

            //Alternative
            //RemotingConfiguration.RegisterWellKnownServiceType(
            //    typeof(MyRemoteObject),
            //    "MyRemoteObjectName",
            //    WellKnownObjectMode.Singleton);

            System.Console.WriteLine("<enter> para sair...");
            System.Console.ReadLine();
        }
Esempio n. 2
0
        public void method()
        {
            BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();

            provider.TypeFilterLevel = TypeFilterLevel.Full;
            IDictionary props = new Hashtable();
            string      name  = "s";
            int         port  = 8086;

            if (url != null)
            {
                props["port"] = url.Port;
                port          = url.Port;
            }
            else
            {
                props["port"] = 8086;
            }
            if (id != null)
            {
                props["name"] = id;
                name          = id;
            }
            channel = new TcpChannel(props, null, provider);
            //String reference = "tcp://" + GetIPAddress() + ":" + port + "/MyRemoteObjectName";
            mo = new MyRemoteObject(min_delay, max_delay, url);
            RemotingServices.Marshal(mo,
                                     "MyRemoteObjectName/" + name,
                                     typeof(MyRemoteObject));
        }
Esempio n. 3
0
        public void method()
        {
            BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();

            provider.TypeFilterLevel = TypeFilterLevel.Full;
            IDictionary props = new Hashtable();
            string      name  = "s";
            int         port  = 8086;

            if (uri != null)
            {
                props["port"] = uri.Port;
                port          = uri.Port;
            }
            else
            {
                props["port"] = 8086;
            }
            if (id != null)
            {
                props["name"] = id;
                name          = id;
            }
            channel = new TcpChannel(props, null, provider);
            ChannelServices.RegisterChannel(channel, false);
            //String reference = "tcp://" + GetIPAddress() + ":" + port + "/MyRemoteObjectName";

            if (replica == 0)
            {
                mo = new MyRemoteObject(min_delay, max_delay, uri, 0);
                RemotingServices.Marshal(mo,
                                         "MyRemoteObjectName/" + name,
                                         typeof(MyRemoteObject));
                maxCount = 8;
                sendAlive();
            }
            else
            {
                mo = new MyRemoteObject(min_delay, max_delay, uri, 1);
                Console.WriteLine(uri.ToString());
                RemotingServices.Marshal(mo,
                                         "MyRemoteObjectName/" + name,
                                         typeof(MyRemoteObject));

                receiveAlive();
            }
        }
Esempio n. 4
0
        static void Main()
        {
            TcpChannel channel = new TcpChannel();

            ChannelServices.RegisterChannel(channel, true);

            MyRemoteObject obj = (MyRemoteObject)Activator.GetObject(
                typeof(MyRemoteObject),
                "tcp://localhost:8086/MyRemoteObjectName");

            try
            {
                Console.WriteLine(obj.MetodoOla());
            }
            catch (SocketException)
            {
                System.Console.WriteLine("Could not locate server");
            }

            Console.ReadLine();
        }