Results 1 to 7 of 7

Thread: Problem passing context map with createSession()

  1. #1
    bartley is offline Registered User
    Name: Chris Bartley
    Organization: Carnegie Mellon University Robotics Institute
    Project: The Telepresence Robot Kit (TeRK)
    Join Date
    Dec 2005
    Posts
    52

    Problem passing context map with createSession()

    I'm having trouble passing a context map in a call to createSession(). I'm using the chat room code from Connections #2. I modified it in two ways: first, I added the following to the Glacier2 config to turn on context forwarding:

    Code:
    Glacier2.Client.ForwardContext=1
    Glacier2.Server.ForwardContext=1
    I then create the context map and call createSession() as follows:

    Code:
    final Map<String, String> contextMap = new HashMap<String, String>();
    contextMap.put("foo", "bar");
    chatSessionPrx = ChatSessionPrxHelper.uncheckedCast(router.createSession(id, pw, contextMap));
    However, when I print out the contents of the context map received by checkPermissions() in the permissions verifier, it's always empty. What am I doing wrong?

    BTW, the context maps created in ChatRoom's enter() method are passed, so I know it works at least some of the time.

    This post seems to be asking the same question, but there's no answer given:

    Finally, speaking of context maps, are they ever mutated? That is, for the ChatRoom class, is it safe to create the map once and store it as a class member rather than creating a new one with every call to enter()?

    Thanks!

  2. #2
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Which version of Ice for Java are you using? Note that, prior to 3.0.1, there were bugs with respect to contexts in the Java and C# implementations. If you are still using 3.0 or earlier, can you please upgrade to 3.0.1 and let us know whether that fixes it?

    When you pass a context map to the Ice run time, it keeps a copy of that map, so if you change the context map after passing it to the session, that will not affect the session.

    Cheers,

    Michi.

  3. #3
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    No contexts are forwarded to the permission verifier when sessions are established. This will be changed in the next Ice 3.1 release.

  4. #4
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    Quote Originally Posted by bartley
    Finally, speaking of context maps, are they ever mutated? That is, for the ChatRoom class, is it safe to create the map once and store it as a class member rather than creating a new one with every call to enter()?
    Ice doesn't modify the contexts that you pass. You can store them somewhere and reuse them. Alternatively, you can simply set the context as default context on the proxy, then you don't have to pass it explicitly at all.

  5. #5
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Quote Originally Posted by marc
    No contexts are forwarded to the permission verifier when sessions are established. This will be changed in the next Ice 3.1 release.
    Sorry Chris, I was looking at the Ice 3.1 source tree when I claimed that the router would pass along the context to the permission verifier.

    If you can't distinguish between humans and robots using the username, I think your best alternative is to use two router instances.

    Take care,
    - Mark

  6. #6
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Of course, you could also modify the Glacier2 sources yourself. The changes are trivial.

    - Mark

  7. #7
    bartley is offline Registered User
    Name: Chris Bartley
    Organization: Carnegie Mellon University Robotics Institute
    Project: The Telepresence Robot Kit (TeRK)
    Join Date
    Dec 2005
    Posts
    52
    Wow, thanks for all the helpful replies--you guys are great.

    I'll probably just go with two routers. Any timeframe on when Ice 3.1 will be released?

    Ice doesn't modify the contexts that you pass. You can store them somewhere and reuse them.
    Good, thanks, that's what I had hoped.

    Alternatively, you can simply set the context as default context on the proxy, then you don't have to pass it explicitly at all.
    Oooo, even better, thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 09-07-2007, 11:38 AM
  2. Ice Context propagation problem (C++, Java)
    By joel vennin in forum Help Center
    Replies: 2
    Last Post: 04-20-2006, 11:08 AM
  3. Glacier2 Router tag createSession as AMI
    By StuartA in forum Comments
    Replies: 1
    Last Post: 11-05-2005, 10:01 PM
  4. Link problem using a string to class map
    By MKoleoso in forum Help Center
    Replies: 2
    Last Post: 07-03-2005, 11:02 AM
  5. passing a context to a locator
    By robert in forum Help Center
    Replies: 4
    Last Post: 10-23-2004, 11:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •