4 Replies Latest reply on Mar 1, 2007 6:57 PM by fatbatman

    InvokerCallbackHandler.getSessionId() ?

    fatbatman Novice


      How do I get the "sessionId" from InvokerCallbackHandler.addListener(InvokerCallbackHandler callbackHandler) so its the same as that returned from InvocationRequest.getSessionId() for a particular client.

      thanks in advance

      regards

      James

        • 1. Re: InvokerCallbackHandler.getSessionId() ?
          Tom Elrod Master

          Hi James. Not sure what you are asking for? The InvocationRequest.getSessionId() comes from when a remoting Client is created and set on the InvocationRequest when making an invocation (although user could set their own session id via the Client's setter method).

          As for a session id being associated with the InvokerCallbackHandler, there really isn't one, so this is throwing me. Are you saying you want one so know from which client the callback handler originally came from?

          • 2. Re: InvokerCallbackHandler.getSessionId() ?
            fatbatman Novice

            Hi Tom,

            Yes I'd like to know which client the InvokerCallbackHandler is from so I can send a callback to a specific client.

            I'm investigating using remoting with something akin to a online chat system.
            I was planning on having some kind of custom login method, in which I would get the InvocationRequest.getSessionId() and link it to the username. I'd then like to link the InvokerCallbackHandler to that username also, so its possilbe to send a callback to a specific user.

            For example if user1 wants to send a chat message to user2 only.

            If there is some other best practice for this kind of situation please let me know.

            Thanks, James

            • 3. Re: InvokerCallbackHandler.getSessionId() ?
              Ron Sigal Master

              Hi James,

              I think the reason your initial question was a bit ambiguous (besides the fact that addListener() isn't a method of InvokerCallbackHandler) might have been that, on the client side, an InvokerCallbackHandler can be reused by many Clients and callback Connectors, so it's not associated with a particular Client.

              On the server side, however, when the addListener() method is called on your ServerInvocationHandler, the InvokerCallbackHandler that gets passed *is* associated with a particular call to Client.addListener(). You can get the sessionId of that Client by casting the InvokerCallbackHandler to org.jboss.remoting.callback.ServerInvokerCallbackHandler and calling its method getClientSessionId().

              Hope that helps.

              • 4. Re: InvokerCallbackHandler.getSessionId() ?
                fatbatman Novice

                Hi Ron,

                ServerInvokerCallbackHandler.getClientSessionId() is exactly what I was looking for.

                Many thanks to both of you

                James