Skip to content

Commit

Permalink
TUIKit upgrade version 7.4.4643
Browse files Browse the repository at this point in the history
  • Loading branch information
harperhpliu committed Aug 15, 2023
1 parent b48fabb commit 53482e7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,27 @@ public class RoomPresenterImpl extends RoomPresenter implements IRoomCallback, R
private AccessRoomConstants.SelfRoomStatus mSelfRoomStatus = NO_IN_ROOM;
private final TUIRoomDefine.LoginUserInfo mSelfInfo;

private CountDownLatch mLoginLatch;
private CountDownLatch mLeaveRoomLatch;
private CountDownLatch mJoinRoomLatch;
private CountDownLatch mSendMsgLatch;
private CountDownLatch mGiveUpRoomManagerLatch;
private AtomicBoolean mIsProcess = new AtomicBoolean(false);

private RoomPresenterImpl() {
mLoginLatch = new CountDownLatch(1);
RoomEngineManager.loginRoomEngine(new TUIRoomDefine.ActionCallback() {
@Override
public void onSuccess() {
mLoginLatch.countDown();
}

@Override
public void onError(TUICommonDefine.Error error, String message) {
Log.e(TAG, "loginRoomEngine onError error=" + error + " message=" + message);
mLoginLatch.countDown();
}
});
addObserver();
mRoomManager = new RoomManagerImpl();
mRoomTaskStoreHouse = new RoomTaskStoreHouse();
Expand Down Expand Up @@ -83,6 +97,7 @@ public void createRoom() {
mRoomTaskStoreHouse.postTask(new Runnable() {
@Override
public void run() {
waitUntilLogin();
processCreateRoom();
}
});
Expand All @@ -103,6 +118,14 @@ private void processCreateRoom() {
mIsProcess.set(false);
}

private void waitUntilLogin() {
try {
mLoginLatch.await(WAIT_TIME_S, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

private void waitUntilExitPreRoom() {
waitUntilGiveUpRoomOwner();
Log.d(TAG, "waitUntilExitPreRoom");
Expand Down Expand Up @@ -235,6 +258,7 @@ public void enterRoom(RoomMsgData roomMsgData) {
mRoomTaskStoreHouse.postTask(new Runnable() {
@Override
public void run() {
waitUntilLogin();
processEnterRoom(roomMsgData);
}
});
Expand Down Expand Up @@ -305,6 +329,7 @@ public void inviteOtherMembersToJoin(RoomMsgData roomMsgData) {
mRoomTaskStoreHouse.postTask(new Runnable() {
@Override
public void run() {
waitUntilLogin();
mRoomManager.inviteOtherMembersToJoin(roomMsgData, mSelfInfo);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public static RoomEngineManager sharedInstance(Context context) {
return sInstance;
}

public static void loginRoomEngine(TUIRoomDefine.ActionCallback callback) {
TUIRoomEngine.login(TUILogin.getAppContext(), TUILogin.getSdkAppId(), TUILogin.getUserId(),
TUILogin.getUserSig(), callback);
}

public void startScreenCapture() {
if (!DrawOverlaysPermissionUtil.isGrantedDrawOverlays()) {
Log.w(TAG, "startScreenCapture no permission");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public void init(Context context) {
initExtension();
initRoomMessage();
initSignalingListener();
initLoginObserver();
}

private void initExtension() {
Expand All @@ -71,37 +70,6 @@ private void initRoomMessage() {

}

private void initLoginObserver() {
TUICore.registerEvent(EVENT_LOGIN_STATE_CHANGED, EVENT_SUB_KEY_USER_LOGIN_SUCCESS, new ITUINotification() {
@Override
public void onNotifyEvent(String key, String subKey, Map<String, Object> param) {
if (TextUtils.equals(key, EVENT_LOGIN_STATE_CHANGED) && TextUtils.equals(subKey,
EVENT_SUB_KEY_USER_LOGIN_SUCCESS)) {
loginRoomEngine();
}
}
});
}

private void loginRoomEngine() {
int sdkAppId = TUILogin.getSdkAppId();
String userId = TUILogin.getUserId();
String userSig = TUILogin.getUserSig();
Log.i(TAG, "TUIRoomEngine.login sdkAppId: " + sdkAppId + " userId=" + userId + " userSig=" + !TextUtils.isEmpty(
userSig) + " thread.name=" + Thread.currentThread().getName());
TUIRoomEngine.login(TUILogin.getAppContext(), sdkAppId, userId, userSig, new TUIRoomDefine.ActionCallback() {
@Override
public void onSuccess() {
Log.i(TAG, "TUIRoomEngine.login onSuccess thread.name=" + Thread.currentThread().getName());
}

@Override
public void onError(TUICommonDefine.Error code, String message) {
Log.e(TAG, "TUIRoomEngine.login onError code=" + code + " message=" + message);
}
});
}

private void initSignalingListener() {
V2TIMManager.getSignalingManager().addSignalingListener(new V2TIMSignalingListener() {
@Override
Expand Down

0 comments on commit 53482e7

Please sign in to comment.