Search in sources :

Example 6 with ApiOutPeer

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

the class MessageDeleteActor method performDelete.

public void performDelete(final Peer peer, final List<Long> rids) {
    final ApiOutPeer outPeer = buidOutPeer(peer);
    final ApiPeer apiPeer = buildApiPeer(peer);
    request(new RequestDeleteMessage(outPeer, rids), new RpcCallback<ResponseSeq>() {

        @Override
        public void onResult(ResponseSeq response) {
            if (deleteStorage.getPendingDeletions().containsKey(peer)) {
                deleteStorage.getPendingDeletions().get(peer).getRids().removeAll(rids);
                saveStorage();
            }
            updates().onUpdateReceived(new SeqUpdate(response.getSeq(), response.getState(), UpdateMessageDelete.HEADER, new UpdateMessageDelete(apiPeer, rids).toByteArray()));
        }

        @Override
        public void onError(RpcException e) {
        }
    });
}
Also used : SeqUpdate(im.actor.core.api.base.SeqUpdate) RequestDeleteMessage(im.actor.core.api.rpc.RequestDeleteMessage) ResponseSeq(im.actor.core.api.rpc.ResponseSeq) RpcException(im.actor.core.network.RpcException) UpdateMessageDelete(im.actor.core.api.updates.UpdateMessageDelete) ApiOutPeer(im.actor.core.api.ApiOutPeer) ApiPeer(im.actor.core.api.ApiPeer)

Example 7 with ApiOutPeer

use of im.actor.core.api.ApiOutPeer 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)

Aggregations

ApiOutPeer (im.actor.core.api.ApiOutPeer)7 RpcException (im.actor.core.network.RpcException)5 ApiPeer (im.actor.core.api.ApiPeer)3 SeqUpdate (im.actor.core.api.base.SeqUpdate)3 ResponseSeq (im.actor.core.api.rpc.ResponseSeq)2 ResponseSeqDate (im.actor.core.api.rpc.ResponseSeqDate)2 ResponseVoid (im.actor.core.api.rpc.ResponseVoid)2 ApiMessage (im.actor.core.api.ApiMessage)1 ApiPeerType (im.actor.core.api.ApiPeerType)1 ApiTextMessage (im.actor.core.api.ApiTextMessage)1 RequestArchiveChat (im.actor.core.api.rpc.RequestArchiveChat)1 RequestClearChat (im.actor.core.api.rpc.RequestClearChat)1 RequestDeleteChat (im.actor.core.api.rpc.RequestDeleteChat)1 RequestDeleteMessage (im.actor.core.api.rpc.RequestDeleteMessage)1 RequestFavouriteDialog (im.actor.core.api.rpc.RequestFavouriteDialog)1 RequestMessageRead (im.actor.core.api.rpc.RequestMessageRead)1 RequestMessageReceived (im.actor.core.api.rpc.RequestMessageReceived)1 RequestMessageRemoveReaction (im.actor.core.api.rpc.RequestMessageRemoveReaction)1 RequestMessageSetReaction (im.actor.core.api.rpc.RequestMessageSetReaction)1 RequestSendMessage (im.actor.core.api.rpc.RequestSendMessage)1