12.2.3. User properties change event handler

The handler signature:

void onUserUpdated(ClientEndpointEvent e)

In the handler’s body, call the getEndpoint method on the ‘e’ parameter. It returns the endpoint that invoked the handler. Then call the endpoint’s getUser method which has the following signature:

public MembershipUser getUser()

Using the MembershipUser API, you can check if the user is a named user with certain permissions, Guest or Stateless Guest. The example below demonstrates the handler implementation:

public void onUserUpdated(ClientEndpointEvent e) {
    ClientEndpoint clientEndpoint = e.getEndpoint();
    MembershipUser user = clientEndpoint.getUser();
    System.out.println(String.format("Membership User: %s ", user.getName()));
    if(user.hasRoles()) {
        System.out.println("Roles:");
        for(String role: user.getRoles())
            System.out.println("  " + role);
    }			
}

TABLE OF CONTENTS