Search in sources :

Example 1 with ActorRef

use of im.actor.runtime.actors.ActorRef in project actor-platform by actorapp.

the class EncryptedPeerActor method spawnSession.

private SessionActor spawnSession(final PeerSession session) {
    ActorRef res = system().actorOf(Props.create(new ActorCreator() {

        @Override
        public EncryptedSessionActor create() {
            return new EncryptedSessionActor(context(), session);
        }
    }), getPath() + "/k_" + RandomUtils.nextRid());
    SessionActor cont = new SessionActor(res, session);
    if (activeSessions.containsKey(session.getTheirKeyGroupId())) {
        activeSessions.get(session.getTheirKeyGroupId()).getSessions().add(cont);
    } else {
        ArrayList<SessionActor> l = new ArrayList<>();
        l.add(cont);
        activeSessions.put(session.getTheirKeyGroupId(), new SessionHolder(session.getTheirKeyGroupId(), l));
    }
    return cont;
}
Also used : ActorRef(im.actor.runtime.actors.ActorRef) ArrayList(java.util.ArrayList) ActorCreator(im.actor.runtime.actors.ActorCreator)

Example 2 with ActorRef

use of im.actor.runtime.actors.ActorRef in project actor-platform by actorapp.

the class CallManagerActor method doEndCall.

private void doEndCall(long callId) {
    Log.d(TAG, "doEndCall (" + callId + ")");
    // 
    // Action ALWAYS comes from UI side and we need only stop call actor
    // explicitly and it will do the rest.
    // 
    ActorRef currentCallActor = runningCalls.remove(callId);
    if (currentCallActor != null) {
        if (answeredCalls.contains(callId)) {
            currentCallActor.send(PoisonPill.INSTANCE);
        } else {
            currentCallActor.send(new CallActor.RejectCall());
        }
    }
    // 
    if (currentCall != null && currentCall == callId) {
        currentCall = null;
        provider.onCallEnd(callId);
        if (isBeeping) {
            isBeeping = false;
            provider.stopOutgoingBeep();
        }
    }
}
Also used : ActorRef(im.actor.runtime.actors.ActorRef) AbsCallActor(im.actor.core.modules.calls.peers.AbsCallActor)

Example 3 with ActorRef

use of im.actor.runtime.actors.ActorRef in project actor-platform by actorapp.

the class CallManagerActor method doAnswerCall.

private void doAnswerCall(final long callId) {
    Log.d(TAG, "doAnswerCall (" + callId + ")");
    // If not already answered
    if (!answeredCalls.contains(callId)) {
        // 
        // Mark as answered
        // 
        answeredCalls.add(callId);
        // 
        // Sending answer message to actor.
        // 
        ActorRef ref = runningCalls.get(callId);
        if (ref != null) {
            ref.send(new CallActor.AnswerCall());
        }
        // 
        if (currentCall != null && currentCall == callId) {
            provider.onCallAnswered(callId);
        }
    }
}
Also used : ActorRef(im.actor.runtime.actors.ActorRef) AbsCallActor(im.actor.core.modules.calls.peers.AbsCallActor)

Example 4 with ActorRef

use of im.actor.runtime.actors.ActorRef in project actor-platform by actorapp.

the class CallBusActor method preStart.

@Override
public void preStart() {
    super.preStart();
    ActorRef ref = system().actorOf(getPath() + "/peer", () -> {
        return new PeerCallActor(peerCallback, CallBusActor.this.selfSettings, context());
    });
    this.peerCall = new PeerCallInt(ref);
}
Also used : ActorRef(im.actor.runtime.actors.ActorRef)

Example 5 with ActorRef

use of im.actor.runtime.actors.ActorRef 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

ActorRef (im.actor.runtime.actors.ActorRef)5 AbsCallActor (im.actor.core.modules.calls.peers.AbsCallActor)2 ArrayList (java.util.ArrayList)2 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 ActorCreator (im.actor.runtime.actors.ActorCreator)1