private RespokeGroupMessage buildGroupMessage ( JSONObject source ) throws JSONException { if ( source == null ) { throw new IllegalArgumentException ( "source cannot be null" ) ; } final JSONObject header = source . getJSONObject ( "header" ) ; final String endpointID = header . getString ( "from" ) ; final RespokeEndpoint endpoint = getEndpoint ( endpointID , false ) ; final String groupID = header . getString ( "channel" ) ; RespokeGroup group = getGroup ( groupID ) ; if ( group == null ) { group = new RespokeGroup ( groupID , signalingChannel , this , false ) ; groups . put ( groupID , group ) ; } final String message = source . getString ( "message" ) ; final Date timestamp ; if ( ! header . isNull ( "timestamp" ) ) { timestamp = new Date ( header . getLong ( "timestamp" ) ) ; } else { // Just use the current time if no date is specified in the header data timestamp = new Date ( ) ; } return new RespokeGroupMessage ( message , group , endpoint , timestamp ) ; }
Build a group message from a JSON object . The format of the JSON object would be the format that comes over the wire from Respoke when receiving a pubsub message . This same format is used when retrieving message history .