use of com.backendless.exceptions.BackendlessFault in project Android-SDK by Backendless.
the class Messaging method pollMessages.
protected void pollMessages(String channelName, String subscriptionId, final AsyncCallback<List<Message>> responder) {
try {
checkChannelName(channelName);
if (subscriptionId == null)
throw new IllegalArgumentException(ExceptionMessage.NULL_SUBSCRIPTION_ID);
Invoker.invokeAsync(MESSAGING_MANAGER_SERVER_ALIAS, "pollMessages", new Object[] { channelName, subscriptionId }, new AsyncCallback<Object[]>() {
@Override
public void handleResponse(Object[] response) {
if (responder != null)
responder.handleResponse(response.length == 0 ? new ArrayList<Message>() : Arrays.asList((Message[]) response));
}
@Override
public void handleFault(BackendlessFault fault) {
if (responder != null)
responder.handleFault(fault);
}
});
} catch (Throwable e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.exceptions.BackendlessFault in project Android-SDK by Backendless.
the class Messaging method publish.
public void publish(String channelName, Object message, PublishOptions publishOptions, DeliveryOptions deliveryOptions, final AsyncCallback<MessageStatus> responder) {
try {
channelName = getCheckedChannelName(channelName);
if (message == null)
throw new IllegalArgumentException(ExceptionMessage.NULL_MESSAGE);
Invoker.invokeAsync(MESSAGING_MANAGER_SERVER_ALIAS, "publish", new Object[] { channelName, message, publishOptions, deliveryOptions }, responder);
} catch (Throwable e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.exceptions.BackendlessFault in project Android-SDK by Backendless.
the class Messaging method subscribe.
public void subscribe(final String channelName, final AsyncCallback<List<Message>> subscriptionResponder, SubscriptionOptions subscriptionOptions, final int pollingInterval, final AsyncCallback<Subscription> responder) {
try {
checkChannelName(channelName);
if (pollingInterval < 0)
throw new IllegalArgumentException(ExceptionMessage.WRONG_POLLING_INTERVAL);
subscribeForPollingAccess(channelName, subscriptionOptions, new AsyncCallback<String>() {
@Override
public void handleResponse(String subscriptionId) {
Subscription subscription = new Subscription();
subscription.setChannelName(channelName);
subscription.setSubscriptionId(subscriptionId);
if (pollingInterval != 0)
subscription.setPollingInterval(pollingInterval);
subscription.onSubscribe(subscriptionResponder);
if (responder != null)
responder.handleResponse(subscription);
}
@Override
public void handleFault(BackendlessFault fault) {
if (responder != null)
responder.handleFault(fault);
}
});
} catch (Throwable e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.exceptions.BackendlessFault in project Android-SDK by Backendless.
the class Messaging method registerDeviceOnServer.
public void registerDeviceOnServer(String deviceToken, final List<String> channels, final long expiration, final AsyncCallback<String> responder) {
try {
if (deviceToken == null)
throw new IllegalArgumentException(ExceptionMessage.NULL_DEVICE_TOKEN);
DeviceRegistration deviceRegistration = new DeviceRegistration();
deviceRegistration.setDeviceId(DEVICE_ID);
deviceRegistration.setOs(OS);
deviceRegistration.setOsVersion(OS_VERSION);
deviceRegistration.setDeviceToken(deviceToken);
deviceRegistration.setChannels(channels);
if (expiration != 0)
deviceRegistration.setExpiration(new Date(expiration));
Invoker.invokeAsync(DEVICE_REGISTRATION_MANAGER_SERVER_ALIAS, "registerDevice", new Object[] { deviceRegistration }, new AsyncCallback<String>() {
@Override
public void handleResponse(String response) {
if (responder != null)
responder.handleResponse(response);
}
@Override
public void handleFault(BackendlessFault fault) {
if (responder != null)
responder.handleFault(fault);
}
});
} catch (Throwable e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
use of com.backendless.exceptions.BackendlessFault in project Android-SDK by Backendless.
the class Persistence method remove.
protected <E> void remove(final E entity, final AsyncCallback<Long> responder) {
try {
if (entity == null)
throw new IllegalArgumentException(ExceptionMessage.NULL_ENTITY);
AsyncCallback<Object> removalCallback = new AsyncCallback<Object>() {
@Override
public void handleResponse(Object response) {
FootprintsManager.getInstance().Inner.removeFootprintForObject(BackendlessSerializer.serializeToMap(entity), entity);
if (responder == null)
return;
responder.handleResponse(((Number) response).longValue());
}
@Override
public void handleFault(BackendlessFault fault) {
if (responder != null)
responder.handleFault(fault);
}
};
Map<String, Object> entityMap = BackendlessSerializer.serializeToMap(entity);
FootprintsManager.getInstance().Inner.putMissingPropsToEntityMap(entity, entityMap);
Invoker.invokeAsync(PERSISTENCE_MANAGER_SERVER_ALIAS, "remove", new Object[] { BackendlessSerializer.getSimpleName(entity.getClass()), entityMap }, removalCallback);
} catch (Throwable e) {
if (responder != null)
responder.handleFault(new BackendlessFault(e));
}
}
Aggregations