Search in sources :

Example 1 with RequestSendMessage

use of im.actor.core.api.rpc.RequestSendMessage 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)1 ApiPeer (im.actor.core.api.ApiPeer)1 SeqUpdate (im.actor.core.api.base.SeqUpdate)1 RequestSendMessage (im.actor.core.api.rpc.RequestSendMessage)1 ResponseSeqDate (im.actor.core.api.rpc.ResponseSeqDate)1 UpdateMessageSent (im.actor.core.api.updates.UpdateMessageSent)1 RpcException (im.actor.core.network.RpcException)1