use of com.connectsdk.service.netcast.NetcastHttpServer in project butter-android by butterproject.
the class NetcastTVService method connect.
@Override
public void connect() {
if (state != State.INITIAL) {
Log.w(Util.T, "already connecting; not trying to connect again: " + state);
// don't try to connect again while connected
return;
}
if (!(serviceConfig instanceof NetcastTVServiceConfig)) {
ServiceConfig.ServiceConfigListener serviceConfigListener = serviceConfig.getListener();
serviceConfig = new NetcastTVServiceConfig(serviceConfig.getServiceUUID());
serviceConfig.setListener(serviceConfigListener);
}
if (DiscoveryManager.getInstance().getPairingLevel() == PairingLevel.ON) {
if (((NetcastTVServiceConfig) serviceConfig).getPairingKey() != null && ((NetcastTVServiceConfig) serviceConfig).getPairingKey().length() != 0) {
sendPairingKey(((NetcastTVServiceConfig) serviceConfig).getPairingKey());
} else {
showPairingKeyOnTV();
}
Util.runInBackground(new Runnable() {
@Override
public void run() {
httpServer = new NetcastHttpServer(NetcastTVService.this, getServiceDescription().getPort(), mTextChangedListener);
httpServer.setSubscriptions(subscriptions);
httpServer.start();
}
});
} else {
hConnectSuccess();
}
}
Aggregations