Greeetings,

Like many others, I’m running into a bit of difficulty getting my head
around the asynchronous RPC mindset. I’ve done a substantial amount of
reading in the forums (found the excellent “beer” example) and in
simple cases, I get it, however in more complex cases – I’m finding
I’m still at a bit of a loss. Please consider the following three
methods within a network utility class I’m writing. I’ve distilled
them to just the essentials:

 // Return true if the host is reachable from the server
    public boolean pingHost(String host){
       return pingImp(host);
    }

    // Return true if the port is open on the host (ping it before
checking)
    public boolean checkPort(String host, int port){
       if (ping(host)){
           return checkPortImpl(host, port);
       }
       return false;
    }

    // Return true if the username is valid (ping it and check port 23
first)
    public boolean checkLogin(String host, String username){
        if (ping(host)){
            if (checkPort(host, 23)){
                return checkLoginImpl(host, username);
            }
        }
        return false;
    }

The implementation methods for all three of these functions make RPC
calls to a server which is performing the network activity.

The key goal I’m trying to achieve is that the process only continues
after each step succeeds (e.g. the port checkPort only occurs after a
successful ping and so forth).

Use case #1: the pingHost function will be used on its own to ping
multiple systems
Use case #2: the checkPort  function will also be used on its own to
check status of various TCP/UDP ports (however it should only proceed
if ping function succeeds)
Use case #4; the checkLogin function will check for valid logins
(however, I don’t want it to proceed unless the ping and checkport
tests succeed)

It seems like I can’t simply create an “OnSuccess chain” here, because
the path isn’t linear – it varies depending on “who’s” calling the
methods and what they’re trying to do. On the other hand, I don’t want
to have multiple versions of these implementations just so I can chain
off the OnSuccess methods.

Can anyone make any general suggestions as to how I might organize or
restructure this so that I can call these subsequent functions
dependant on the results of earlier RPC calls?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to