use of com.connectsdk.service.webos.WebOSTVServiceSocketClient in project butter-android by butterproject.
the class WebOSTVService method connect.
@Override
public void connect() {
if (this.socket == null) {
this.socket = new WebOSTVServiceSocketClient(this, WebOSTVServiceSocketClient.getURI(this));
this.socket.setListener(mSocketListener);
}
if (!this.isConnected())
this.socket.connect();
}
use of com.connectsdk.service.webos.WebOSTVServiceSocketClient in project butter-android by butterproject.
the class WebOSWebAppSession method connect.
private void connect(final Boolean joinOnly, final ResponseListener<Object> connectionListener) {
if (socket != null && socket.getState() == WebOSTVServiceSocketClient.State.CONNECTING) {
if (connectionListener != null) {
connectionListener.onError(new ServiceCommandError(0, "You have a connection request pending, please wait until it has finished", null));
}
return;
}
if (isConnected()) {
if (connectionListener != null)
connectionListener.onSuccess(null);
return;
}
mConnectionListener = new ResponseListener<ServiceCommand<ResponseListener<Object>>>() {
@Override
public void onError(ServiceCommandError error) {
if (socket != null)
disconnectFromWebApp();
if (connectionListener != null) {
if (error == null) {
error = new ServiceCommandError(0, "Unknown error connecting to web app", null);
}
connectionListener.onError(error);
}
}
@Override
public void onSuccess(ServiceCommand<ResponseListener<Object>> object) {
ResponseListener<Object> finalConnectionListener = new ResponseListener<Object>() {
@Override
public void onError(ServiceCommandError error) {
disconnectFromWebApp();
if (connectionListener != null)
connectionListener.onError(error);
}
@Override
public void onSuccess(Object object) {
connected = true;
if (connectionListener != null)
connectionListener.onSuccess(object);
}
};
service.connectToWebApp(WebOSWebAppSession.this, joinOnly, finalConnectionListener);
}
};
if (socket != null) {
if (socket.isConnected())
mConnectionListener.onSuccess(null);
else
socket.connect();
} else {
socket = new WebOSTVServiceSocketClient(service, WebOSTVServiceSocketClient.getURI(service));
socket.setListener(mSocketListener);
socket.connect();
}
}
Aggregations