throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Service is not connected yet.');
}
+ var that = this;
var result = native_.call('RemoteAppControlService_disconnect', {
deviceId: this._deviceId
}, function(result) {
if (native_.isFailure(result)) {
native_.callIfPossible(errorCallback, native_.getErrorObject(result));
+ } else {
+ updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, that);
+ native_.callIfPossible(successCallback, that);
}
});
if (native_.isFailure(result)) {
throw native_.getErrorObject(result);
- } else {
- updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, this);
}
-
- native_.callIfPossible(successCallback, this);
};
RemoteAppControlService.prototype.start = function() {
if (this.connectionState != ConnectionState.CONNECTED)
throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Service is not connected yet.');
+ var that = this;
var result = native_.call('AppCommunicationClientService_disconnect', {
deviceId: this._deviceId
}, function(result) {
if (native_.isFailure(result)) {
native_.callIfPossible(errorCallback, native_.getErrorObject(result));
} else {
- native_.callIfPossible(successCallback, this);
+ updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, that);
+ native_.callIfPossible(successCallback, that);
}
});
if (native_.isFailure(result)) {
throw native_.getErrorObject(result);
- } else {
- updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, this);
}
};
if (!service)
return LogAndCreateTizenError(AbortError, "Service is NULL");
- const int error = conv_service_disconnect(service);
+ int error = conv_service_disconnect(service);
if (CONV_ERROR_NONE != error) {
- // TODO: Handle error
trace_conv_error(error, __LINE__, "conv_service_disconnect");
return LogAndCreateTizenError(AbortError, "conv_service_disconnect [fail]");
}
- return TizenSuccess();
+ conv_service_connection_state_e state = CONV_SERVICE_CONNECTION_STATE_NONE;
+ error = conv_service_get_connection_state(service, &state);
+ if (CONV_ERROR_NONE != error) {
+ LoggerE("Error gathering state [%d] : %s", error, get_error_message(error));
+ return LogAndCreateTizenError(AbortError, "Error gathering state");
+ } else {
+ LoggerD("state: %d" , state);
+
+ }
+ if (CONV_SERVICE_CONNECTION_STATE_NOT_CONNECTED == state) {
+ return TizenSuccess();
+ } else {
+ LoggerE("Service is still connected, reporting error");
+ return LogAndCreateTizenError(AbortError, "Disconnecting failed.");
+ }
}
return LogAndCreateTizenError(AbortError, "Service with specified type does not exist");
}
- const int error = conv_service_disconnect(service);
+ int error = conv_service_disconnect(service);
if (CONV_ERROR_NONE != error) {
return LogAndCreateTizenError(AbortError, "conv_service_disconnect [Fail]");
} else {
LoggerI("Disconnected from the remote service");
}
- return TizenSuccess();
+ conv_service_connection_state_e state = CONV_SERVICE_CONNECTION_STATE_NONE;
+ error = conv_service_get_connection_state(service, &state);
+ if (CONV_ERROR_NONE != error) {
+ LoggerE("Error gathering state [%d] : %s", error, get_error_message(error));
+ return LogAndCreateTizenError(AbortError, "Error gathering state");
+ } else {
+ LoggerD("state: %d" , state);
+
+ }
+ if (CONV_SERVICE_CONNECTION_STATE_NOT_CONNECTED == state) {
+ return TizenSuccess();
+ } else {
+ LoggerE("Service is still connected, reporting error");
+ return LogAndCreateTizenError(AbortError, "Disconnecting failed.");
+ }
}
TizenResult ConvergenceRemoteAppControlService::Start(const bool reply, const int cur_listener_id) {