@Override public void onUnexpectedError(Exception e) { event.unsentException = e; mDataHandler.updateEventState(event, Event.SentState.UNDELIVERED); if (null != callback) { callback.onUnexpectedError(e); } } });
@Override public void onNetworkError(Exception e) { event.unsentException = e; mDataHandler.updateEventState(event, Event.SentState.UNDELIVERED); if (null != callback) { callback.onNetworkError(e); } }
@Override public void onNetworkError(Exception e) { event.unsentException = e; mDataHandler.updateEventState(event, Event.SentState.UNDELIVERED); try { callback.onNetworkError(e); } catch (Exception anException) { Log.e(LOG_TAG, "sendEvent exception " + anException.getMessage(), anException); } }
@Override public void onUnexpectedError(Exception e) { event.unsentException = e; mDataHandler.updateEventState(event, Event.SentState.UNDELIVERED); try { callback.onUnexpectedError(e); } catch (Exception anException) { Log.e(LOG_TAG, "sendEvent exception " + anException.getMessage(), anException); } } };
@Override public void onMatrixError(MatrixError e) { event.unsentMatrixError = e; mDataHandler.updateEventState(event, Event.SentState.UNDELIVERED); if (MatrixError.isConfigurationErrorCode(e.errcode)) { mDataHandler.onConfigurationError(e.errcode); } else { try { callback.onMatrixError(e); } catch (Exception anException) { Log.e(LOG_TAG, "sendEvent exception " + anException.getMessage(), anException); } } }
@Override public void onSuccess(MXEncryptEventContentResult encryptEventContentResult) { // update the event content with the encrypted data event.type = encryptEventContentResult.mEventType; // Add the "m.relates_to" data to the encrypted event here JsonObject encryptedContent = encryptEventContentResult.mEventContent.getAsJsonObject(); if (relatesTo != null) { encryptedContent.add("m.relates_to", relatesTo); } event.updateContent(encryptedContent); mDataHandler.decryptEvent(event, null); // sending in progress mDataHandler.updateEventState(event, Event.SentState.SENDING); mDataHandler.getDataRetriever().getRoomsRestClient().sendEventToRoom(event.eventId, getRoomId(), encryptEventContentResult.mEventType, encryptEventContentResult.mEventContent.getAsJsonObject(), localCB); }
mDataHandler.updateEventState(roomMediaMessage.getEvent(), Event.SentState.SENDING);
/** * Cancel the event sending. * Any media upload will be cancelled too. * The event becomes undeliverable. * * @param event the message */ public void cancelEventSending(final Event event) { if (null != event) { if ((Event.SentState.UNSENT == event.mSentState) || (Event.SentState.SENDING == event.mSentState) || (Event.SentState.WAITING_RETRY == event.mSentState) || (Event.SentState.ENCRYPTING == event.mSentState)) { // the message cannot be sent anymore mDataHandler.updateEventState(event, Event.SentState.UNDELIVERED); } List<String> urls = event.getMediaUrls(); MXMediaCache cache = mDataHandler.getMediaCache(); for (String url : urls) { cache.cancelUpload(url); cache.cancelDownload(cache.downloadIdFromUrl(url)); } } }
mDataHandler.updateEventState(roomMediaMessage.getEvent(), Event.SentState.UNSENT); mRoom.storeOutgoingEvent(roomMediaMessage.getEvent()); mDataHandler.getStore().commit();
@Override public void onSuccess(final CreatedEvent createdEvent) { if (null != getStore()) { // remove the tmp event getStore().deleteEvent(event); } // replace the tmp event id by the final one boolean isReadMarkerUpdated = TextUtils.equals(getReadMarkerEventId(), event.eventId); // update the event with the server response event.eventId = createdEvent.eventId; event.originServerTs = System.currentTimeMillis(); mDataHandler.updateEventState(event, Event.SentState.SENT); // the message echo is not yet echoed if (null != getStore() && !getStore().doesEventExist(createdEvent.eventId, getRoomId())) { getStore().storeLiveRoomEvent(event); } // send the dedicated read receipt asap markAllAsRead(isReadMarkerUpdated, null); if (null != getStore()) { getStore().commit(); } mDataHandler.onEventSent(event, prevEventId); try { callback.onSuccess(null); } catch (Exception e) { Log.e(LOG_TAG, "sendEvent exception " + e.getMessage(), e); } }
mDataHandler.updateEventState(event, Event.SentState.WAITING_RETRY); try { callback.onNetworkError(null); mDataHandler.updateEventState(event, Event.SentState.ENCRYPTING); mDataHandler.updateEventState(event, Event.SentState.SENDING);