public void getMembers ( final GetGroupMembersCompletionListener completionListener ) { if ( isJoined ( ) ) { if ( ( null != groupID ) && ( groupID . length ( ) > 0 ) ) { String urlEndpoint = "/v1/channels/" + groupID + "/subscribers/" ; signalingChannel . sendRESTMessage ( "get" , urlEndpoint , null , new RespokeSignalingChannel . RESTListener ( ) { @ Override public void onSuccess ( Object response ) { JSONArray responseArray = null ; if ( response != null ) { if ( response instanceof JSONArray ) { responseArray = ( JSONArray ) response ; } else if ( response instanceof String ) { try { responseArray = new JSONArray ( ( String ) response ) ; } catch ( JSONException e ) { // An exception will trigger the error handler } } } if ( null != responseArray ) { final ArrayList < RespokeConnection > nameList = new ArrayList < RespokeConnection > ( ) ; RespokeClient client = clientReference . get ( ) ; if ( null != client ) { for ( int ii = 0 ; ii < responseArray . length ( ) ; ii ++ ) { try { JSONObject eachEntry = ( JSONObject ) responseArray . get ( ii ) ; String newEndpointID = eachEntry . getString ( "endpointId" ) ; String newConnectionID = eachEntry . getString ( "connectionId" ) ; // Do not include ourselves in this list if ( ! newEndpointID . equals ( client . getEndpointID ( ) ) ) { // Get the existing instance for this connection, or create a new one if necessary RespokeConnection connection = client . getConnection ( newConnectionID , newEndpointID , false ) ; if ( null != connection ) { nameList . add ( connection ) ; } } } catch ( JSONException e ) { // Skip unintelligible records } } } // If certain connections present in the members array prior to this method are somehow no longer in the list received from the server, it's assumed a pending onLeave message will handle flushing it out of the client cache after this method completes members . clear ( ) ; members . addAll ( nameList ) ; new Handler ( Looper . getMainLooper ( ) ) . post ( new Runnable ( ) { @ Override public void run ( ) { if ( null != completionListener ) { completionListener . onSuccess ( nameList ) ; } } } ) ; } else { postGetGroupMembersError ( completionListener , "Invalid response from server" ) ; } } @ Override public void onError ( final String errorMessage ) { postGetGroupMembersError ( completionListener , errorMessage ) ; } } ) ; } else { postGetGroupMembersError ( completionListener , "Group name must be specified" ) ; } } else { postGetGroupMembersError ( completionListener , "Not a member of this group anymore." ) ; } }
Get an array containing the members of the group .