Search in sources :

Example 16 with SDKError

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

the class Room method getZoomScale.

/**
 * 获取当前用户的视角缩放比例。
 *
 * @deprecated 该方法已废弃。
 *
 * @note
 * - 该方法为异步调用。
 * - 调用 {@link #zoomChange(double) zoomChange} 或 {@link #moveCamera(CameraConfig) moveCamera} 调整视角缩放比例后,如果需要立即获取最新的缩放比例,可以调用 {@link #getZoomScale(Promise<Number> promise) getZoomScale}[2/2]。
 *
 * @param promise `Promise<Number>` 接口实例,详见 {@link com.herewhite.sdk.domain.Promise Promise}。你可以通过该接口获取 `getZoomScale` 的调用结果:
 *                - 如果方法调用成功,则返回视角缩放比例。
 *                - 如果方法调用失败,则返回错误信息。
 */
public void getZoomScale(final Promise<Number> promise) {
    bridge.callHandler("room.getZoomScale", new OnReturnValue<Object>() {

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

Example 17 with SDKError

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

the class Room method getMemberState.

/**
 * 获取当前的白板工具状态。
 *
 * @note 该方法为异步调用。
 *
 * @param promise `Promise<MemberState>` 接口实例,详见 {@link com.herewhite.sdk.domain.Promise Promise}。你可以通过该接口获取 `getMemberState` 的调用结果:
 *                - 如果方法调用成功,则返回白板工具状态,详见 {@link com.herewhite.sdk.domain.MemberState MemberState}。
 *                - 如果方法调用失败,则返回错误信息。
 */
public void getMemberState(final Promise<MemberState> promise) {
    bridge.callHandler("room.getMemberState", new OnReturnValue<String>() {

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

Example 18 with SDKError

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

the class Room method getScenes.

/**
 * 获取房间当前场景组下的场景列表。
 *
 * @note
 * - 该方法为异步调用。
 * - 调用以下方法修改或新增场景后,可以调用 {@link #getScenes(Promise<Scene[]> promise) getScenes},立即获取最新的场景列表。
 *   - {@link #setScenePath(String path) setScenePath}[1/2]
 *   - {@link #setScenePath(String path, Promise<Boolean> promise) setScenePath}[2/2]
 *   - {@link #putScenes(String, Scene[], int) putScenes}
 *
 * @param promise `Promise<Scene[]>` 接口实例,详见 {@link com.herewhite.sdk.domain.Promise Promise}。你可以通过该接口获取 `getScenes` 的调用结果:
 *                - 如果方法调用成功,则返回场景列表,详见 {@link com.herewhite.sdk.domain.Scene Scene}。
 *                - 如果方法调用失败,则返回错误信息。
 */
public void getScenes(final Promise<Scene[]> promise) {
    bridge.callHandler("room.getScenes", new Object[] {}, new OnReturnValue<Object>() {

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

Example 19 with SDKError

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

the class Room method getRoomState.

/**
 * 获取房间的所有状态。
 *
 * @note
 * - 该方法为异步调用。
 * - 修改房间的状态属性后,无法立即通过 {@link #getRoomState() getRoomState} 获取最新的房间状态。此时,如果需要立即获取最新的房间状态,可以调用 {@link #getRoomState(Promise<RoomState> promise) getRoomState}[2/2] 获取。
 *
 * @param promise `Promise<RoomState>` 接口实例,详见 {@link com.herewhite.sdk.domain.Promise Promise}。你可以通过该接口获取 `getRoomState` 的调用结果:
 *                - 如果方法调用成功,则返回房间所有状态,详见 {@link com.herewhite.sdk.domain.RoomState RoomState}。
 *                - 如果方法调用失败,则返回错误信息。
 */
public void getRoomState(final Promise<RoomState> promise) {
    bridge.callHandler("room.state.getRoomState", new OnReturnValue<Object>() {

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

Example 20 with SDKError

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

the class Room method getSceneState.

/**
 * 获取房间当前场景组下的场景状态。
 *
 * @note
 * - 该方法为异步调用。
 * - 调用以下方法修改或新增场景后,你可以通过 {@link #getSceneState(Promise<SceneState> promise) getSceneState} 立即获取最新的场景状态。
 *   - {@link #setScenePath(String path) setScenePath}[1/2]
 *   - {@link #setScenePath(String path, Promise<Boolean> promise) setScenePath}[2/2]
 *   - {@link #putScenes(String, Scene[], int)}
 *
 * @param promise `Promise<SceneState>` 接口实例,详见 {@link com.herewhite.sdk.domain.Promise Promise}。你可以通过该接口获取 `getSceneState` 的调用结果:
 *                - 如果方法调用成功,则返回场景状态,详见 {@link com.herewhite.sdk.domain.SceneState SceneState}。
 *                - 如果方法调用失败,则返回错误信息。
 */
public void getSceneState(final Promise<SceneState> promise) {
    bridge.callHandler("room.getSceneState", new Object[] {}, new OnReturnValue<Object>() {

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

Aggregations

SDKError (com.herewhite.sdk.domain.SDKError)38 JSONObject (org.json.JSONObject)18 JsonSyntaxException (com.google.gson.JsonSyntaxException)13 WhiteSdk (com.herewhite.sdk.WhiteSdk)12 WhiteSdkConfiguration (com.herewhite.sdk.WhiteSdkConfiguration)12 JsonObject (com.google.gson.JsonObject)10 Room (com.herewhite.sdk.Room)10 RoomParams (com.herewhite.sdk.RoomParams)10 RoomPhase (com.herewhite.sdk.domain.RoomPhase)7 RoomState (com.herewhite.sdk.domain.RoomState)7 AbstractRoomCallbacks (com.herewhite.sdk.AbstractRoomCallbacks)5 CommonCallback (com.herewhite.sdk.CommonCallback)5 Test (org.junit.Test)5 RoomCallbacks (com.herewhite.sdk.RoomCallbacks)4 View (android.view.View)3 ConvertException (com.herewhite.sdk.domain.ConvertException)3 FontFace (com.herewhite.sdk.domain.FontFace)3 Scene (com.herewhite.sdk.domain.Scene)3 SceneState (com.herewhite.sdk.domain.SceneState)3 WindowParams (com.herewhite.sdk.domain.WindowParams)3