Search in sources :

Example 1 with UpdateEventBusDisposed

use of im.actor.core.api.updates.UpdateEventBusDisposed in project actor-platform by actorapp.

the class EventBusModule method onEventBusUpdate.

public synchronized void onEventBusUpdate(Object update) {
    if (update instanceof UpdateEventBusMessage) {
        UpdateEventBusMessage busMessage = (UpdateEventBusMessage) update;
        ActorRef dest = subscribers.get(busMessage.getId());
        if (dest != null) {
            dest.send(new EventBusActor.EventBusMessage(busMessage.getSenderId(), busMessage.getSenderDeviceId(), busMessage.getMessage()));
        // Log.d("EVENTBUS", "Delivered");
        } else {
            // Log.d("EVENTBUS", "Not Delivered");
            if (!pendingMessages.containsKey(busMessage.getId())) {
                pendingMessages.put(busMessage.getId(), new ArrayList<>());
            }
            pendingMessages.get(busMessage.getId()).add(update);
        }
    } else if (update instanceof UpdateEventBusDeviceConnected) {
        UpdateEventBusDeviceConnected deviceConnected = (UpdateEventBusDeviceConnected) update;
        ActorRef dest = subscribers.get(deviceConnected.getId());
        if (dest != null) {
            dest.send(new EventBusActor.EventBusDeviceConnected(deviceConnected.getUserId(), deviceConnected.getDeviceId()));
        } else {
            // Log.d("EVENTBUS", "Not Delivered");
            if (!pendingMessages.containsKey(deviceConnected.getId())) {
                pendingMessages.put(deviceConnected.getId(), new ArrayList<>());
            }
            pendingMessages.get(deviceConnected.getId()).add(update);
        }
    } else if (update instanceof UpdateEventBusDeviceDisconnected) {
        UpdateEventBusDeviceDisconnected deviceDisconnected = (UpdateEventBusDeviceDisconnected) update;
        ActorRef dest = subscribers.get(deviceDisconnected.getId());
        if (dest != null) {
            dest.send(new EventBusActor.EventBusDeviceDisconnected(deviceDisconnected.getUserId(), deviceDisconnected.getDeviceId()));
        } else {
            Log.d("EVENTBUS", "Not Delivered");
            if (!pendingMessages.containsKey(deviceDisconnected.getId())) {
                pendingMessages.put(deviceDisconnected.getId(), new ArrayList<>());
            }
            pendingMessages.get(deviceDisconnected.getId()).add(update);
        }
    } else if (update instanceof UpdateEventBusDisposed) {
        UpdateEventBusDisposed disposed = (UpdateEventBusDisposed) update;
        ActorRef dest = subscribers.get(disposed.getId());
        if (dest != null) {
            dest.send(new EventBusActor.EventBusDisposed());
        } else {
            // Log.d("EVENTBUS", "Not Delivered");
            if (!pendingMessages.containsKey(disposed.getId())) {
                pendingMessages.put(disposed.getId(), new ArrayList<>());
            }
            pendingMessages.get(disposed.getId()).add(update);
        }
    }
}
Also used : UpdateEventBusMessage(im.actor.core.api.updates.UpdateEventBusMessage) UpdateEventBusDeviceDisconnected(im.actor.core.api.updates.UpdateEventBusDeviceDisconnected) UpdateEventBusDisposed(im.actor.core.api.updates.UpdateEventBusDisposed) UpdateEventBusDisposed(im.actor.core.api.updates.UpdateEventBusDisposed) ActorRef(im.actor.runtime.actors.ActorRef) ArrayList(java.util.ArrayList) UpdateEventBusDeviceConnected(im.actor.core.api.updates.UpdateEventBusDeviceConnected) UpdateEventBusDeviceConnected(im.actor.core.api.updates.UpdateEventBusDeviceConnected)

Aggregations

UpdateEventBusDeviceConnected (im.actor.core.api.updates.UpdateEventBusDeviceConnected)1 UpdateEventBusDeviceDisconnected (im.actor.core.api.updates.UpdateEventBusDeviceDisconnected)1 UpdateEventBusDisposed (im.actor.core.api.updates.UpdateEventBusDisposed)1 UpdateEventBusMessage (im.actor.core.api.updates.UpdateEventBusMessage)1 ActorRef (im.actor.runtime.actors.ActorRef)1 ArrayList (java.util.ArrayList)1