Search in sources :

Example 1 with WebOSTVMouseSocketConnection

use of com.connectsdk.service.webos.WebOSTVMouseSocketConnection in project butter-android by butterproject.

the class WebOSTVService method connectMouse.

private void connectMouse(final WebOSTVMouseSocketConnection.WebOSTVMouseSocketListener successHandler) {
    if (mouseSocket != null)
        return;
    String uri = "ssap://com.webos.service.networkinput/getPointerInputSocket";
    ResponseListener<Object> listener = new ResponseListener<Object>() {

        @Override
        public void onSuccess(Object response) {
            try {
                JSONObject jsonObj = (JSONObject) response;
                String socketPath = (String) jsonObj.get("socketPath");
                mouseSocket = new WebOSTVMouseSocketConnection(socketPath, successHandler);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onError(ServiceCommandError error) {
            Log.w(Util.T, "Connect mouse error: " + error.getMessage());
        }
    };
    ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, null, true, listener);
    request.send();
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) ServiceCommandError(com.connectsdk.service.command.ServiceCommandError) ResponseListener(com.connectsdk.service.capability.listeners.ResponseListener) WebOSTVMouseSocketConnection(com.connectsdk.service.webos.WebOSTVMouseSocketConnection) ServiceCommand(com.connectsdk.service.command.ServiceCommand)

Aggregations

ResponseListener (com.connectsdk.service.capability.listeners.ResponseListener)1 ServiceCommand (com.connectsdk.service.command.ServiceCommand)1 ServiceCommandError (com.connectsdk.service.command.ServiceCommandError)1 WebOSTVMouseSocketConnection (com.connectsdk.service.webos.WebOSTVMouseSocketConnection)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1