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;
}
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();
}
}
}
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);
}
}
}
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);
}
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);
}
}
}
Aggregations