示例#1
0
 static void InvokeRemoteObject(RemoteObject service)
 {
     // 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());
 }
示例#2
0
        static void Main(string[] args)
        {
            var channel = new IpcChannel();

            ChannelServices.RegisterChannel(channel, false);

            var remoteType = new WellKnownClientTypeEntry(
                typeof(RemoteObject),
                "ipc://localhost:9090/RemoteObject.rem");

            RemotingConfiguration.RegisterWellKnownClientType(remoteType);

            // Create a message sink
            string objectUri;
            var    messageSink = channel.CreateMessageSink(
                "ipc://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());
            }

            // Create an instance of the remote object.
            var 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());

            Console.ReadKey();
        }
    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());
    }
示例#4
0
    public static void Main(string[] args)
    {
        //<snippet31>
        // Create the channel.
        TcpClientChannel clientChannel = new TcpClientChannel("Client", null);

        //</snippet31>

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

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

        RemotingConfiguration.RegisterWellKnownClientType(remoteType);

        //<snippet32>
        // Create a message sink.
        string objectUri;

        System.Runtime.Remoting.Messaging.IMessageSink messageSink =
            clientChannel.CreateMessageSink(
                "tcp://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());
        }
        //</snippet32>

        //<snippet33>
        // Parse the channel's URI.
        string objectUrl  = "tcp://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);
        //</snippet33>

        // 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());
    }
示例#5
0
    [SecurityPermission(SecurityAction.Demand)] //wtf even is this
    public static void Main(string[] args)
    {
        // Krijo channel
        IpcChannel channel = new IpcChannel();

        // Regjistro channel, percakto sigurine
        System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);

        // Regjistro se qka do dergohet, dhe ku
        System.Runtime.Remoting.WellKnownClientTypeEntry remoteType =
            new System.Runtime.Remoting.WellKnownClientTypeEntry(
                typeof(RemoteObject),
                "ipc://localhost:9090/RemoteObject.rem");
        System.Runtime.Remoting.RemotingConfiguration.
        RegisterWellKnownClientType(remoteType);
        // Krijo nje pool te mesazheve
        string objectUri;

        System.Runtime.Remoting.Messaging.IMessageSink messageSink =
            channel.CreateMessageSink(
                "ipc://localhost:9090/RemoteObject.rem", null,
                out objectUri);
        Console.WriteLine("URI e pool te mesazheve eshte {0}.",
                          objectUri);
        if (messageSink != null)
        {
            Console.WriteLine("Lloji i pool te mesazheve eshte {0}.",
                              messageSink.GetType().ToString());
        }

        // Krijo instanc te RemoteObject
        RemoteObject service = new RemoteObject();

        // Thirr metoden e RemoteObject
again:
        Console.WriteLine("Klienti po therret remote object.");
        Console.WriteLine("Remote objecti eshte thirrur " + service.GetCount() + " here.");
        // Mundesi e thjeshte per te perseritur thirrjen
        Console.Write("Deshironi t'e perseritni? (1=po, 0=jo): ");
        int repeat = 1;

        try{ repeat = Int32.Parse(Console.ReadLine()); }
        catch { repeat = 1; }
        if (repeat == 1)
        {
            goto again;
        }
    }
示例#6
0
    public static void Main(string[] args)
    {
        //<snippet21>
        // Create the channel.
        IpcChannel channel = new IpcChannel();

        //</snippet21>

        // Register the channel.
        System.Runtime.Remoting.Channels.ChannelServices.
        RegisterChannel(channel);

        // Register as client for remote object.
        System.Runtime.Remoting.WellKnownClientTypeEntry remoteType =
            new System.Runtime.Remoting.WellKnownClientTypeEntry(
                typeof(RemoteObject),
                "ipc://localhost:9090/RemoteObject.rem");
        System.Runtime.Remoting.RemotingConfiguration.
        RegisterWellKnownClientType(remoteType);

        //<snippet22>
        // Create a message sink.
        string objectUri;

        System.Runtime.Remoting.Messaging.IMessageSink messageSink =
            channel.CreateMessageSink(
                "ipc://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());
        }
        //</snippet22>

        // 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());
    }
示例#7
0
    public static void Main(string[] args)
    {
        // Create the client channel.
        IpcClientChannel clientChannel = null;

        if (false)
        {
        }
        else if (args[0] == "1")
        {
            clientChannel = Ctor1();
        }
        else if (args[0] == "2")
        {
            clientChannel = Ctor2();
        }
        else
        {
            throw new ApplicationException("Invalid argument.");
        }

        // Register the channel.
        System.Runtime.Remoting.Channels.ChannelServices.
        RegisterChannel(clientChannel);

        // Register as client for remote object.
        System.Runtime.Remoting.WellKnownClientTypeEntry remoteType =
            new System.Runtime.Remoting.WellKnownClientTypeEntry(
                typeof(RemoteObject),
                "ipc://localhost:9090/RemoteObject.rem");
        System.Runtime.Remoting.RemotingConfiguration.
        RegisterWellKnownClientType(remoteType);

        // 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());
    }
示例#8
0
    public static void Main(string[] args)
    {
        // Create the channel.
        HttpClientChannel channel = new HttpClientChannel();

        // 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);

        // 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());
    }