@Override public void onRetry() { leaveRoom(roomId, callback); } }));
@Override public void onRetry() { sendEventToRoom(transactionId, roomId, eventType, content, callback); } }));
@Override public void onRetry() { sendMessage(transactionId, roomId, message, callback); } }));
.sendMessage(event.eventId, getRoomId(), JsonUtils.toMessage(event.getContent()), localCB); } else { mDataHandler.getDataRetriever().getRoomsRestClient() .sendEventToRoom(event.eventId, getRoomId(), event.getType(), event.getContentAsJsonObject(), localCB);
@Override public void onRetry() { sendStateEvent(roomId, eventType, stateKey, params, callback); } }));
@Override public void onRetry() { updateTopic(roomId, topic, callback); } }));
@Override public void onRetry() { createRoom(params, callback); } }));
@Override public void onRetry() { forgetRoom(roomId, callback); } }));
@Override public void onRetry() { addTag(roomId, tag, order, callback); } }));
@Override public void onRetry() { banFromRoom(roomId, userIdAndReason, callback); } }));
mProfileRestClient = new ProfileRestClient(hsConfig); mPresenceRestClient = new PresenceRestClient(hsConfig); mRoomsRestClient = new RoomsRestClient(hsConfig); mPushRulesRestClient = new PushRulesRestClient(hsConfig);
@Override public void onRetry() { sendStateEvent(roomId, eventType, null, params, callback); } }));
/** * Update the room's topic. * * @param aTopic the new topic * @param callback the async callback */ public void updateTopic(final String aTopic, final ApiCallback<Void> callback) { mDataHandler.getDataRetriever().getRoomsRestClient().updateTopic(getRoomId(), aTopic, new RoomInfoUpdateCallback<Void>(callback) { @Override public void onSuccess(Void info) { getState().topic = aTopic; super.onSuccess(info); } }); }
mRoomsRestClient.createRoom(params, new SimpleApiCallback<CreateRoomResponse>(callback) { @Override public void onSuccess(CreateRoomResponse info) {
/** * Forget the room. * * @param callback the callback for when done */ public void forget(final ApiCallback<Void> callback) { mDataHandler.getDataRetriever().getRoomsRestClient().forgetRoom(getRoomId(), new SimpleApiCallback<Void>(callback) { @Override public void onSuccess(Void info) { if (mDataHandler.isAlive()) { // don't call onSuccess.deleteRoom because it moves an existing room to historical store IMXStore store = mDataHandler.getStore(getRoomId()); if (null != store) { store.deleteRoom(getRoomId()); store.commit(); } try { callback.onSuccess(info); } catch (Exception e) { Log.e(LOG_TAG, "forget exception " + e.getMessage(), e); } } } }); }
/** * Add a tag to a room. * Use this method to update the order of an existing tag. * * @param tag the new tag to add to the room. * @param order the order. * @param callback the operation callback */ private void addTag(String tag, Double order, final ApiCallback<Void> callback) { // sanity check if ((null != tag) && (null != order)) { mDataHandler.getDataRetriever().getRoomsRestClient().addTag(getRoomId(), tag, order, callback); } else { if (null != callback) { callback.onSuccess(null); } } }
/** * Ban a user from the room. * * @param userId the user id * @param reason ban reason * @param callback the async callback */ public void ban(String userId, String reason, ApiCallback<Void> callback) { UserIdAndReason userIdAndReason = new UserIdAndReason(); userIdAndReason.userId = userId; if (!TextUtils.isEmpty(reason)) { userIdAndReason.reason = reason; } mDataHandler.getDataRetriever().getRoomsRestClient().banFromRoom(getRoomId(), userIdAndReason, callback); }
private void changeDisplayname(String roomId, String displayname) { Map<String, Object> params = new HashMap<>(); params.put("displayname", displayname); params.put("membership", "join"); session.getRoomsApiClient().sendStateEvent(roomId, "m.room.member", session.getMyUserId(), params, new SimpleApiCallback<Void>()); }
@Override public void onSuccess(String info) { super.onSuccess(info); session.getRoomsApiClient().updateTopic(info, phoneNumber, new SimpleApiCallback<Void>()); changeDisplayname(info, getContactName(phoneNumber, context)); Room room = store.getRoom(info); SendMesageToRoom(room, body, type); } });
@Override public void onUploadComplete(final String uploadId, final String contentUri) { Room room = getRoomByPhonenumber(phoneNumber); JsonObject json = new JsonObject(); json.addProperty("body", fileName); json.addProperty("msgtype", type); json.addProperty("url", contentUri); JsonObject info = new JsonObject(); info.addProperty("mimetype", contentType); json.add("info", info); session.getRoomsApiClient().sendEventToRoom( String.valueOf(transaction), room.getRoomId(), "m.room.message", json, new SimpleApiCallback<Event>() ); transaction++; } }