Skip to main content



      Home
Home » Eclipse Projects » Eclipse Scout » Get IP Address from Client Session
Get IP Address from Client Session [message #1831659] Wed, 26 August 2020 04:22 Go to next message
Eclipse UserFriend
Hello,
is there a way to get IP address from client that created the session in eclipse scout SDK ?
Kind Regards

[Updated on: Wed, 26 August 2020 04:23] by Moderator

Re: Get IP Address from Client Session [message #1831672 is a reply to message #1831659] Wed, 26 August 2020 06:39 Go to previous messageGo to next message
Eclipse UserFriend
Not by default. But you could provide your own Java implementation of a "org.eclipse.scout.rt.ui.html.UiSession" by using Scout's BEANS / @Replace mechanism. Override #getOrCreateClientSession and add the IP information from the HttpServletRequest to the jsonStartupReq.getSessionStartupParams() Map. Later you can access the startup params via AbstractDesktop#getStartupRequestParam(String).

Cheers
André
Re: Get IP Address from Client Session [message #1832013 is a reply to message #1831672] Fri, 04 September 2020 16:11 Go to previous messageGo to next message
Eclipse UserFriend
Hello André,
I have tried that but I am stuck in the fact that the map returned is unmodifiable, so it is not possible to add a new param to that existing map.
Kind Regards
Re: Get IP Address from Client Session [message #1832036 is a reply to message #1832013] Mon, 07 September 2020 03:21 Go to previous message
Eclipse UserFriend
Just create a new map instance then. You could override UiSession#createAndStartClientSession to do that (untested):

  protected IClientSession createAndStartClientSession(Locale locale, UserAgent userAgent, Map<String, String> sessionStartupParams) {
    Map<String, String> modfiableMap = new HashMap<>(sessionStartupParams);
    modifiableMap.put("ipAddress", "[value]");
    return BEANS.get(ClientSessionProvider.class).provide(ClientRunContexts.copyCurrent()
        .withLocale(locale)
        .withUserAgent(userAgent)
        .withProperties(modifiableMap)); // Make startup parameters available at {@link PropertyMap#CURRENT} during client session is starting.
  }

Cheers
André

[Updated on: Mon, 07 September 2020 07:26] by Moderator

Previous Topic:Where locate static file?
Next Topic:Table Sort 2 Columns
Goto Forum:
  


Current Time: Wed May 07 08:41:47 EDT 2025

Powered by FUDForum. Page generated in 0.29085 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top