Search in sources :

Example 1 with RoomMember

use of com.herewhite.sdk.domain.RoomMember in project whiteboard-android by netless-io.

the class Room method getRoomMembers.

/**
 * 获取房间的用户列表。
 *
 * @note
 * - 该方法为异步调用。
 * - 房间的用户列表仅包含互动模式(具有读写权限)的用户,不包含订阅模式(只读权限)的用户。
 *
 * @param promise `Promise<RoomMember[]>` 接口实例,详见 {@link com.herewhite.sdk.domain.Promise Promise}。你可以通过该接口获取 `getRoomMembers` 的调用结果:
 *                - 如果方法调用成功,则返回用户列表,详见 {@link com.herewhite.sdk.domain.RoomMember RoomMember}。
 *                - 如果方法调用失败,则返回错误信息。
 */
public void getRoomMembers(final Promise<RoomMember[]> promise) {
    bridge.callHandler("room.getRoomMembers", new Object[] {}, new OnReturnValue<Object>() {

        @Override
        public void onValue(Object o) {
            try {
                promise.then(gson.fromJson(String.valueOf(o), RoomMember[].class));
            } catch (AssertionError a) {
                throw a;
            } catch (JsonSyntaxException e) {
                Logger.error("An JsonSyntaxException occurred while parse json from getRoomMembers", e);
                promise.catchEx(new SDKError(e.getMessage()));
            } catch (Throwable e) {
                Logger.error("An exception occurred in getRoomMembers promise then method", e);
                promise.catchEx(new SDKError(e.getMessage()));
            }
        }
    });
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) RoomMember(com.herewhite.sdk.domain.RoomMember) SDKError(com.herewhite.sdk.domain.SDKError) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.JSONObject)

Aggregations

JsonObject (com.google.gson.JsonObject)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 RoomMember (com.herewhite.sdk.domain.RoomMember)1 SDKError (com.herewhite.sdk.domain.SDKError)1 JSONObject (org.json.JSONObject)1