Search in sources :

Example 6 with SeqUpdate

use of im.actor.core.api.base.SeqUpdate in project actor-platform by actorapp.

the class SenderActor method performSendApiContent.

private void performSendApiContent(final Peer peer, final long rid, ApiMessage message, final WakeLock wakeLock) {
    final ApiOutPeer outPeer = buidOutPeer(peer);
    final ApiPeer apiPeer = buildApiPeer(peer);
    if (outPeer == null || apiPeer == null) {
        return;
    }
    request(new RequestSendMessage(outPeer, rid, message, null, null), new RpcCallback<ResponseSeqDate>() {

        @Override
        public void onResult(ResponseSeqDate response) {
            self().send(new MessageSent(peer, rid));
            updates().onUpdateReceived(new SeqUpdate(response.getSeq(), response.getState(), UpdateMessageSent.HEADER, new UpdateMessageSent(apiPeer, rid, response.getDate()).toByteArray()));
            wakeLock.releaseLock();
        }

        @Override
        public void onError(RpcException e) {
            self().send(new MessageError(peer, rid));
            wakeLock.releaseLock();
        }
    });
}
Also used : UpdateMessageSent(im.actor.core.api.updates.UpdateMessageSent) SeqUpdate(im.actor.core.api.base.SeqUpdate) RequestSendMessage(im.actor.core.api.rpc.RequestSendMessage) RpcException(im.actor.core.network.RpcException) ApiOutPeer(im.actor.core.api.ApiOutPeer) ResponseSeqDate(im.actor.core.api.rpc.ResponseSeqDate) UpdateMessageSent(im.actor.core.api.updates.UpdateMessageSent) ApiPeer(im.actor.core.api.ApiPeer)

Example 7 with SeqUpdate

use of im.actor.core.api.base.SeqUpdate in project actor-platform by actorapp.

the class SequenceActor method onReceive.

//
// Messages
//
@Override
public void onReceive(Object message) {
    if (message instanceof Invalidate || message instanceof SeqUpdateTooLong || message instanceof ForceInvalidate) {
        if (!isValidated) {
            return;
        }
        invalidate();
    } else if (message instanceof SeqUpdate || message instanceof FatSeqUpdate) {
        if (!isValidated) {
            stash();
            return;
        }
        int seq;
        byte[] state;
        int type;
        byte[] body;
        List<ApiUser> users = null;
        List<ApiGroup> groups = null;
        if (message instanceof SeqUpdate) {
            seq = ((SeqUpdate) message).getSeq();
            state = ((SeqUpdate) message).getState();
            type = ((SeqUpdate) message).getUpdateHeader();
            body = ((SeqUpdate) message).getUpdate();
        } else {
            seq = ((FatSeqUpdate) message).getSeq();
            state = ((FatSeqUpdate) message).getState();
            type = ((FatSeqUpdate) message).getUpdateHeader();
            body = ((FatSeqUpdate) message).getUpdate();
            users = ((FatSeqUpdate) message).getUsers();
            groups = ((FatSeqUpdate) message).getGroups();
        }
        onUpdateReceived(seq, state, type, body, users, groups);
    } else if (message instanceof ExecuteAfter) {
        if (!isValidated) {
            stash();
            return;
        }
        onExecuteAfter((ExecuteAfter) message);
    } else if (message instanceof PushSeq) {
        if (!isValidated) {
            stash();
            return;
        }
        onPushSeqReceived(((PushSeq) message).seq, ((PushSeq) message).authId);
    } else if (message instanceof WeakUpdate) {
        WeakUpdate weakUpdate = (WeakUpdate) message;
        onWeakUpdateReceived(weakUpdate.getUpdateHeader(), weakUpdate.getUpdate(), weakUpdate.getDate());
    } else {
        super.onReceive(message);
    }
}
Also used : FatSeqUpdate(im.actor.core.api.base.FatSeqUpdate) FatSeqUpdate(im.actor.core.api.base.FatSeqUpdate) SeqUpdate(im.actor.core.api.base.SeqUpdate) WeakUpdate(im.actor.core.api.base.WeakUpdate) ExecuteAfter(im.actor.core.modules.sequence.internal.ExecuteAfter) ArrayList(java.util.ArrayList) List(java.util.List) SeqUpdateTooLong(im.actor.core.api.base.SeqUpdateTooLong)

Aggregations

SeqUpdate (im.actor.core.api.base.SeqUpdate)7 RpcException (im.actor.core.network.RpcException)5 ApiOutPeer (im.actor.core.api.ApiOutPeer)4 ResponseSeq (im.actor.core.api.rpc.ResponseSeq)4 ArrayList (java.util.ArrayList)3 ApiPeer (im.actor.core.api.ApiPeer)2 ApiUser (im.actor.core.api.ApiUser)2 ApiUserOutPeer (im.actor.core.api.ApiUserOutPeer)2 FatSeqUpdate (im.actor.core.api.base.FatSeqUpdate)2 WeakUpdate (im.actor.core.api.base.WeakUpdate)2 RequestAddContact (im.actor.core.api.rpc.RequestAddContact)2 RequestRemoveContact (im.actor.core.api.rpc.RequestRemoveContact)2 RequestSearchContacts (im.actor.core.api.rpc.RequestSearchContacts)2 UpdateContactsAdded (im.actor.core.api.updates.UpdateContactsAdded)2 UpdateContactsRemoved (im.actor.core.api.updates.UpdateContactsRemoved)2 Contact (im.actor.core.entity.Contact)2 User (im.actor.core.entity.User)2 AbsModule (im.actor.core.modules.AbsModule)2 Modules (im.actor.core.modules.Modules)2 ApiSupportConfiguration (im.actor.core.modules.api.ApiSupportConfiguration)2