2 Replies Latest reply on Apr 2, 2010 1:25 PM by tofor

    Communicate with app on client

      In my deployment I have an application running along with a web browser with a GateIn portlet.  I need to send an action command from the portlet client to the application running on the same machine.  There are several of these pairs running on the same network, along with the GateIn server.

       

      Previously I was using a servlet, and the method I used was to find the IP address of the client, send a message to all the applications, and each app would check if the IP matched its own.  The app with the matching IP would execute the command.

       

      Now I'm using a portlet, and there does not seem to be any way of finding the IP address of the client machine.

       

      So my question is this:

       

      Is there in fact some way of finding the IP of a client machine from within a portlet?

      If not, how can I send a message to an application running on the client machine?

        • 1. Re: Communicate with app on client
          mstruk

          As far as I know there is no standard way to get to this information via Portlet API.

           

          But you can do a GateIn specific hack:

          {code}

          PortletRequest request = myReq;

          String remoteIP = ((org.gatein.pc.portlet.impl.jsr168.api.RenderRequestImpl) request).getRealRequest().getRemoteAddr();

          {code}

           

          Where myReq is any kind of PortletRequest (RenderRequest, ActionRequest, EventRequest, ResourceRequest ...)

           

          As for the design of your application, I'm not sure I get it, but it sounds like you're connecting from your portal application to your client desktops, each of whom is running a browser and another app you need to be in sync with your browser. It sounds bad - your clients should connect to the server and not vice versa (along the lines of server push paradigm - http://en.wikipedia.org/wiki/Push_technology). Also sending a message destined for one, to all of them is bad. You should know the identity of each client app in your portal app, and only send the message to the one app it's destined to.

           

          - marko

          • 2. Re: Communicate with app on client

            Thank you Marko.  That was exactly what I needed: a GateIn specific hack.  As for the architecture, have no fear: it will change.  This is a "temporary" transitional workaround until we can fix things the way they are supposed to be.