public void setPresence ( Object newPresence , final Respoke . TaskCompletionListener completionListener ) { if ( isConnected ( ) ) { Object presenceToSet = newPresence ; if ( null == presenceToSet ) { presenceToSet = "available" ; } JSONObject typeData = new JSONObject ( ) ; JSONObject data = new JSONObject ( ) ; try { typeData . put ( "type" , presenceToSet ) ; data . put ( "presence" , typeData ) ; final Object finalPresence = presenceToSet ; signalingChannel . sendRESTMessage ( "post" , "/v1/presence" , data , new RespokeSignalingChannel . RESTListener ( ) { @ Override public void onSuccess ( Object response ) { presence = finalPresence ; Respoke . postTaskSuccess ( completionListener ) ; } @ Override public void onError ( final String errorMessage ) { Respoke . postTaskError ( completionListener , errorMessage ) ; } } ) ; } catch ( JSONException e ) { Respoke . postTaskError ( completionListener , "Error encoding presence to json" ) ; } } else { Respoke . postTaskError ( completionListener , "Can't complete request when not connected. Please reconnect!" ) ; } }
Set the presence on the client session