public void sendMessage ( String message , boolean push , boolean ccSelf , final Respoke . TaskCompletionListener completionListener ) { if ( ( null != signalingChannel ) && ( signalingChannel . connected ) ) { try { JSONObject data = new JSONObject ( ) ; data . put ( "to" , endpointID ) ; data . put ( "message" , message ) ; data . put ( "push" , push ) ; data . put ( "ccSelf" , ccSelf ) ; signalingChannel . sendRESTMessage ( "post" , "/v1/messages" , data , new RespokeSignalingChannel . RESTListener ( ) { @ Override public void onSuccess ( Object response ) { Respoke . postTaskSuccess ( completionListener ) ; } @ Override public void onError ( final String errorMessage ) { Respoke . postTaskError ( completionListener , errorMessage ) ; } } ) ; } catch ( JSONException e ) { Respoke . postTaskError ( completionListener , "Error encoding message" ) ; } } else { Respoke . postTaskError ( completionListener , "Can't complete request when not connected. Please reconnect!" ) ; } }
Send a message to the endpoint through the infrastructure .