Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/split im group #2

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions App/AgoraEducation/Logic/DataStructure/FcrAppClosure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ typealias FcrAppStringCompletion = (String) -> (Void)
typealias FcrAppBoolCompletion = (Bool) -> (Void)
typealias FcrAppDateCompletion = ((Date) -> Void)
typealias FcrAppUICreatedRoomResultCompletion = (FcrAppUICreatedRoomResult) -> (Void)
typealias TestTokenSuccessCompletion = (String,String) -> (Void)
17 changes: 17 additions & 0 deletions App/AgoraEducation/Logic/FcrAppCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class FcrAppCenter: NSObject {
armin.failureDelegate = self

do {
localStorage.writeData(true,
key: .testMode)
if let mode = try? localStorage.readStringEnumData(key: .uiMode,
type: FcrAppUIMode.self) {
self.uiMode = mode
Expand Down Expand Up @@ -280,6 +282,21 @@ class FcrAppCenter: NSObject {
self?.delegate?.onLoginExpired()
}
}

func getConfigV3(role:Int, roomUuid:String, userUuid:String, success: TestTokenSuccessCompletion?){
let url = urlGroup.TestToken(role: role, roomUuid: roomUuid, userUuid: userUuid)
armin.request(url: url, method: .get, event: "get-config-v3") {object in

let data = try object.dataConvert(type: [String: Any].self)

let appId = try data.getValue(of: "appId",
type: String.self)

let token = try data.getValue(of: "token",
type: String.self)
success?(appId, token)
}
}
}

extension FcrAppCenter: FcrAppArminFailureDelegate {
Expand Down
7 changes: 7 additions & 0 deletions App/AgoraEducation/Logic/Providers/FcrAppURLGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,11 @@ class FcrAppURLGroup {
let url = array.joined(separator: "/")
return url
}

func TestToken(role:Int, roomUuid:String, userUuid:String) -> String {
let array = [host, edu, "v3",
"rooms", roomUuid, "roles", role.string, "users", userUuid, "token"]
let url = array.joined(separator: "/")
return url
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//

import AgoraUIBaseViews
import AgoraClassroomSDK_iOS
import AgoraWidgets

extension FcrAppUIQuickStartViewController: AgoraUIContentContainer {
func initViews() {
Expand All @@ -20,7 +22,7 @@ extension FcrAppUIQuickStartViewController: AgoraUIContentContainer {
for: .touchUpInside)

headerView.signButton.addTarget(self,
action: #selector(onSignInButtonPressed(_ :)),
action: #selector(onImGroupButtonPressed(_ :)),
for: .touchUpInside)

// Join room view
Expand Down Expand Up @@ -109,6 +111,48 @@ private extension FcrAppUIQuickStartViewController {
animated: true)
}

@objc func onImGroupButtonPressed(_ sender: UIButton) {
let FilePathName: String = NSTemporaryDirectory()
let vc = FcrAppUIJoinRoomController(center: center) { [weak self] (roomUuid, userUuid) in
self?.center.getConfigV3(role: AgoraEduUserRole.student.rawValue, roomUuid: roomUuid, userUuid: userUuid) { [weak self] appId, token in
let userId = userUuid
let userName = userId
let userRole = AgoraEduUserRole.student

let roomType = AgoraEduRoomType.lecture
let roomId = roomUuid
let roomName = roomId


let region = AgoraEduRegion.CN
let streamLatency = AgoraEduLatencyLevel.low

// Is the watermark displayed in the room
let hasWatermark = false

let options = AgoraEduLaunchConfig(userName: userName,
userUuid: userId,
userRole: userRole,
roomName: roomName,
roomUuid: roomId,
roomType: roomType,
appId: appId,
token: token)

options.mediaOptions.latencyLevel = streamLatency
options.region = region


self?.joinClassroom(config: options,
hasWatermark: hasWatermark)

}
}

presentViewController(vc,
animated: true)
}

@objc func onSignInButtonPressed(_ sender: UIButton) {
if !center.tester.isTest {
showLoginViewController()
Expand All @@ -120,6 +164,7 @@ private extension FcrAppUIQuickStartViewController {
}

@objc func onJoinButtonPressed(_ sender: UIButton) {

let joinRoomView = contentView.roomInputView.joinRoomView

guard let roomId = joinRoomView.roomIdTextField.getText() else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class FcrAppUIQuickStartHeaderView: UIView,
testTag.text = "Tester"

// Sign button
signButton.setTitle("fcr_login_free_button_login_sign".localized(),
signButton.setTitle("IM分组",
for: .normal)

signButton.setTitleColor(FcrAppUIColorGroup.fcr_white,
Expand Down
12 changes: 12 additions & 0 deletions App/AgoraEducation/UI/Root/FcrAppUICoreViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import AgoraClassroomSDK_iOS
import AgoraUIBaseViews
import AgoraProctorSDK
import AgoraWidgets

class FcrAppUICoreViewController: FcrAppUIViewController {
let center: FcrAppCenter
Expand Down Expand Up @@ -102,7 +103,18 @@ class FcrAppUICoreViewController: FcrAppUIViewController {
hasWatermark: hasWatermark)

AgoraClassroomSDK.setDelegate(self)
let sel = NSSelectorFromString("setEnvironment:")
AgoraClassroomSDK.perform(sel, with: center.urlGroup.environment.intValue)
let version = AgoraClassroomSDK.version()
// 大班分组
let chat: AgoraWidgetConfig
if(config.roomType == AgoraEduRoomType.lecture){
chat = AgoraWidgetConfig(with: AgoraChatEasemobWidgetGroup.self, widgetId: "easemobIM")
}else{
chat = AgoraWidgetConfig(with: AgoraChatEasemobWidget.self, widgetId: "easemobIM")
}

config.widgets[chat.widgetId] = chat
AgoraClassroomSDK.launch(config) {
AgoraLoading.hide()
} failure: { [weak self] error in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class FcrAppUIJoinRoomController: FcrAppStartUIPresentedViewController {

private var center: FcrAppCenter

var completion: ((FcrAppJoinRoomPreCheckConfig) -> Void)?
var completion: ((_ roomUuid:String, _ userUuid:String) -> Void)?

init(center: FcrAppCenter,
completion: ((FcrAppJoinRoomPreCheckConfig) -> Void)? = nil) {
completion: ((_ roomUuid:String, _ userUuid:String) -> Void)? = nil) {
self.center = center
self.completion = completion
super.init()
Expand Down Expand Up @@ -45,7 +45,9 @@ class FcrAppUIJoinRoomController: FcrAppStartUIPresentedViewController {

joinView.roomInputView.roomIdTextField.setShowText(center.room.lastId)
joinView.roomInputView.userNameTextField.text = center.localUser?.nickname

joinView.teacherView.isHidden = true
joinView.roleTitleLabel.isHidden = true
joinView.studentView.isHidden = true
joinView.studentView.button.addTarget(self,
action: #selector(onPressedStudentButton(_:)),
for: .touchUpInside)
Expand Down Expand Up @@ -119,36 +121,42 @@ private extension FcrAppUIJoinRoomController {
return
}

let userRole: FcrAppUIUserRole = (joinView.teacherView.button.isSelected ? .teacher : .student)

guard let userId = center.localUser?.userId else {
fatalError()
}

AgoraLoading.loading()

center.room.getRoomInfo(roomId: roomId) { [weak self] object in
AgoraLoading.hide()

let newId = FcrAppRoomUserIdCreater().start(userId: userId,
userName: userName,
userRole: userRole,
roomType: object.sceneType)

let config = FcrAppJoinRoomPreCheckConfig(roomId: roomId,
userId: newId,
userName: userName,
userRole: userRole)

self?.dismiss(animated: true)

self?.completion?(config)

self?.completion = nil
} failure: { [weak self] error in
AgoraLoading.hide()
self?.showErrorToast(error)
}


self.dismiss(animated: true)

self.completion?(roomId, userName)

self.completion = nil
// let userRole: FcrAppUIUserRole = (joinView.teacherView.button.isSelected ? .teacher : .student)
// guard let userId = center.localUser?.userId else {
// fatalError()
// }
//
// AgoraLoading.loading()
//
// center.room.getRoomInfo(roomId: roomId) { [weak self] object in
// AgoraLoading.hide()
//
// let newId = FcrAppRoomUserIdCreater().start(userId: userId,
// userName: userName,
// userRole: userRole,
// roomType: object.sceneType)
//
// let config = FcrAppJoinRoomPreCheckConfig(roomId: roomId,
// userId: newId,
// userName: userName,
// userRole: userRole)
//
// self?.dismiss(animated: true)
//
// self?.completion?(config)
//
// self?.completion = nil
// } failure: { [weak self] error in
// AgoraLoading.hide()
// self?.showErrorToast(error)
// }
}

@objc func onPressedTeacherButton(_ sender: UIButton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ extension FcrAppUIMainViewController: AgoraUIContentContainer {

private extension FcrAppUIMainViewController {
@objc func onJoinButtonPressed(_ sender: UIButton) {
let vc = FcrAppUIJoinRoomController(center: center) { [weak self] config in
self?.joinRoomPreCheck(config: config)
}

presentViewController(vc,
animated: true)
// let vc = FcrAppUIJoinRoomController(center: center) { [weak self] config in
// self?.joinRoomPreCheck(config: config)
// }
//
// presentViewController(vc,
// animated: true)
}

@objc func onCreateButtonPressed(_ sender: UIButton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FcrAppUIAboutViewController: FcrAppUIViewController {
private let isMainLandChina: Bool

///Publish-Time
private let versionTime = ""
private let versionTime = "2024.11.26"

init(dataSource: [FcrAppUISettingItem.AboutUsItem],
isMainLandChina: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class FcrAppUIJoinRoomInputView: UIView,

class FcrAppUIJoinRoomView: UIView,
AgoraUIContentContainer {
private let roleTitleLabel = UILabel()
let roleTitleLabel = UILabel()

let roomInputView = FcrAppUIJoinRoomInputView()

Expand All @@ -159,7 +159,6 @@ class FcrAppUIJoinRoomView: UIView,
addSubview(roleTitleLabel)
addSubview(studentView)
addSubview(teacherView)

teacherView.selected(false)
studentView.selected(true)

Expand Down
8 changes: 4 additions & 4 deletions App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ target 'AgoraEducation' do
pod 'AgoraMediaPlayer_iOS', '1.3.0'
pod 'Agora_Chat_iOS', '1.0.6'
pod 'AgoraRtm_iOS', '1.5.1'
pod 'Whiteboard', '2.16.51'
pod 'Whiteboard', '2.16.107'
pod 'YYModel', '1.0.4'

# open source libs
pod 'AgoraClassroomSDK_iOS', '2.8.101'
Expand All @@ -30,11 +31,10 @@ target 'AgoraEducation' do
pod 'AgoraProctorSDK', '1.0.1'
pod 'AgoraProctorUI', '1.0.0'

pod 'AgoraWidgets', '2.8.101'

pod 'AgoraWidgets', :path => '../../apaas-extapp-ios'
# close source libs
pod 'AgoraUIBaseViews', '2.8.101'
pod 'AgoraEduCore', '2.8.101'
pod 'AgoraEduCore', :path => '../../AgoraEduCore/AgoraEduCore_Local.podspec'
pod 'AgoraWidget', '2.8.0'

# post install, no signing for pods bundle, after xcode 14
Expand Down