Messagelistener confusion (3 posts)

  • Profile picture of villoto villoto1p said 5 months ago:

    Hi all, I’m confused. In the messageReceived method the first parameter is the source (who issues the message), but in the next example of the tutorials, it doesn’t seems.

    public class ClientListener implements MessageListener {
    public void messageReceived(Client source, Message message) {
    if (message instanceof HelloMessage) {
    // do something with the message
    HelloMessage helloMessage = (HelloMessage) message;
    System.out.println(“Client #”+source.getId()+” received: ‘”+helloMessage.getSomething()+”‘”);
    } // else…
    }

    Here, the source is who received the message. This message was sent from the server, therefore it is the issuer and not the client.
    can anybody help me???

  • Profile picture of pspeed pspeed815p said 5 months ago:

    It’s not that kind of source. It’s the source of the message from your local point of view. The endpoint on your end of the connection. On the server, it’s the specific connection back to a client (the HostedConnection)… on the client, it’s the Client… which is the only endpoint in the client.

    What else would we pass? There is no “Server” on the client after all… just the connection back to it represented by Client.

  • Profile picture of villoto villoto1p said 5 months ago:

    Thanks @pspeed , now I understand it!!