Home Help Center

work_pending() how to realize in ICE ??

surfersurfer Member ✭✭
Hello,
I know there are some posts about bi-directional communication and so on but it isn't clear for me.
Is or are there a simple solution(s) to implement a function in an object so that it is possible to receive method calls and to invoke remote method calls?
Exactly the same like the Corba implementation:
for(;;){
// If there is work for the current orb
if(this.orb.work_pending()){
// Do the work:
this.orb.perform_work();
}
else{
// run my code 
}

I've seen some about Glacier2 and so on but it is to heavy for my application or is there no other way?

Please let me know about the simplest solution.

Thanks so long
surfer

Comments

  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Ice is fully multi-threaded, and therefore doesn't have any "main loop". No calls to something equivalent to CORBA's work_pending() or perform_work() are necessary.
  • surfersurfer Member ✭✭
    still not clear

    Hello Marc,

    sorry but how is it possible to place a call to the client at the server side?

    Thats the server code:
    adapter.activate();
    ic.waitForShutdown();
    


    after activate() I'm not able to call or print any method or text.
    But I would like to add there my client call.
    At the documentation page 675/676 there are no solutions to find something to be able to process calls whereas at the same time receiving others.

    How would a solution look like and
    would it be possible that you write some example code?

    Thanks very much !!!
    surfer
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    You can do whatever you like after adapter.activate(). Waiting for some other thread to shutdown the communicator is just one possibility: Ice does not need your thread!

    Cheers,
    Bernard
  • surfersurfer Member ✭✭
    Client Server Communication question

    Hello,

    I've got it.
    But I don't know whether this is the professional way?

    Server 1 Server 2
    Client (Client2) <
    > Server (Client2)
    Server (Client1) <
    > Client (Client1)



    Server 1 on host XYTEST
            .......
            Ice.ObjectAdapter adapter
    		= ic.createObjectAdapterWithEndpoints(
    		    "Client1Adapter", "default -p 10000");  
                Ice.Object object = (Object) new PrinterI();
    	    adapter.add(object, Ice.Util.stringToIdentity("Client1")); //Login ID
            adapter.activate();
            Server server = new Server();
            Server.client_call(args);
            ic.waitForShutdown();
            .........
            
        // +++++++++++++++++++++++++++++++++++++++++++++++    
            
            public static void client_call(String[] args) {
            Client client = new Client();   
            client.start(args);
        }   
            
    

    Client 1 Class
    public static void
        start(String[] args)
        {
            int status = 0;
            Ice.Communicator ic = null;
          try {
                ic = Ice.Util.initialize(args);
                Ice.ObjectPrx base = ic.stringToProxy("Client2:tcp -h XYTEST -p 10000:udp -h XYTEST -p 10000");  // Port
                Suaheli.PrinterPrx printer = Suaheli.PrinterPrxHelper.checkedCast(base);
    	        if (printer == null)
    	        throw new Error("Invalid proxy");
                ........
    

    Server 2 on host XYWIN
            ........
            ic = Ice.Util.initialize(args);
    	    Ice.ObjectAdapter adapter
    		= ic.createObjectAdapterWithEndpoints(
    		    "Client2Adapter", "default -p 10000"); 
    	    Ice.Object object = (Object) new PrinterI();
    	    adapter.add(object, Ice.Util.stringToIdentity("Client2")); //Login name
            ..........
            
            
            // +++++++++++++++++++++++++++++++++++++++++++++++    
            public static void client_call(String[] args) {
            
            Client client = new Client();   
            client.start(args);
        }
    


    Client 2 Class
    public static void
        start(String[] args)
        {
            int status = 0;
            Ice.Communicator ic = null;
          try {
                ic = Ice.Util.initialize(args);
                Ice.ObjectPrx base = ic.stringToProxy("Client1:tcp -h XYWIN -p 10000:udp -h XYWIN -p 10000");  // Port
                Suaheli.PrinterPrx printer = Suaheli.PrinterPrxHelper.checkedCast(base);
    	        if (printer == null)
    	        throw new Error("Invalid proxy");
                ...............
    


    Is this the right way ???
    Ok next with a config file to be use one file for all but the principle?
    Or is there a shorter way ?

    surfer
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Sorry, but I'm afraid it is not clear to me what the question is. What exactly are you not sure about?
  • surfersurfer Member ✭✭
    Client-Server bi-directional communication

    Hello,
    thanks a lot for your quick reply!!

    Sorry but my question is how to set up a clear client server communication in an bi-directional way.

    Is the way I showed correct or is there a better way to do so??

    Please let me know about and how the professional way look like.

    Thanks
    surfer
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    The Ice distribution contains many demos. For example, you could have a look at demo/Ice/callback, or if you want to use bi-directional connections, check out the demo/Ice/bidir.
Sign In or Register to comment.