Skip to content

Commit

Permalink
(ScreenSharing) Implement log file sharing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirBrejcha committed Apr 27, 2021
1 parent 8f056d8 commit 4ee9995
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 52 deletions.
5 changes: 2 additions & 3 deletions ScreenSharing/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ fileprivate let callManager: CallManager = CallManager(client, authService, darw
fileprivate let storyAssembler: StoryAssembler = StoryAssembler(authService: authService, callManager: callManager)

@UIApplicationMain
final class AppDelegate: UIResponder, UIApplicationDelegate, Loggable {
final class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var appName: String { "ScreenSharing" }

override init() {
super.init()
configureDefaultLogging()
Logger.configure(appName: "ScreenSharing")
}

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Expand Down
28 changes: 15 additions & 13 deletions ScreenSharing/Stories/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ final class LoginViewController: UIViewController, LoadingShowable {

override func viewDidLoad() {
super.viewDidLoad()

loginView.setTitle(text: "Screen sharing demo")


let loginHandler: AuthService.LoginCompletion = { [weak self] error in
guard let self = self else { return }
self.hideProgress()
Expand All @@ -24,16 +22,20 @@ final class LoginViewController: UIViewController, LoadingShowable {
self.present(self.storyAssembler.main, animated: true)
}
}

loginView.loginTouchHandler = { [weak self] username, password in
Log.d("Manually Logging in with password")
self?.showLoading(title: "Connecting", details: "Please wait...")
self?.authService.login(
user: username.appendingVoxDomain,
password: password,
loginHandler
)
}

loginView.configure(
title: "Screen sharing demo",
controller: self,
loginHandler: { [weak self] username, password in
Log.d("Manually Logging in with password")
self?.showLoading(title: "Connecting", details: "Please wait...")
self?.authService.login(
user: username.appendingVoxDomain,
password: password,
loginHandler
)
}
)

if authService.possibleToLogin {
Log.d("Automatically Logging in with token")
Expand Down
71 changes: 35 additions & 36 deletions ScreenSharing/Stories/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,45 @@ final class MainViewController:

override func viewDidLoad() {
super.viewDidLoad()

if let displayName = authService.loggedInUserDisplayName {
mainView.setDisplayName(text: "Logged in as \(displayName)")
}

mainView.callTouchHandler = { [weak self] username in
Log.d("Calling \(String(describing: username))")
PermissionsHelper.requestRecordPermissions(includingVideo: true) { error in
if let error = error {
self?.handleError(error)
return
}

guard let self = self else { return }

let beginCall = {
do {
try self.callManager.makeOutgoingCall(to: username ?? "")
self.view.endEditing(true)
self.present(AnimatedTransitionNavigationController(
rootViewController: self.storyAssembler.call), animated: true)
} catch (let error) {
Log.e(error.localizedDescription)
AlertHelper.showError(message: error.localizedDescription, on: self)

mainView.configure(
displayName: "Logged in as \(authService.loggedInUserDisplayName ?? "")",
controller: self,
callHandler: { [weak self] username in
Log.d("Calling \(String(describing: username))")
PermissionsHelper.requestRecordPermissions(includingVideo: true) { error in
if let error = error {
self?.handleError(error)
return
}

guard let self = self else { return }

let beginCall = {
do {
try self.callManager.makeOutgoingCall(to: username ?? "")
self.view.endEditing(true)
self.present(AnimatedTransitionNavigationController(
rootViewController: self.storyAssembler.call), animated: true)
} catch (let error) {
Log.e(error.localizedDescription)
AlertHelper.showError(message: error.localizedDescription, on: self)
}
}

if !self.authService.isLoggedIn {
self.reconnect(onSuccess: beginCall)
} else {
beginCall()
}
}

if !self.authService.isLoggedIn {
self.reconnect(onSuccess: beginCall)
} else {
beginCall()
},
logoutHandler: { [weak self] in
self?.authService.logout {
self?.dismiss(animated: true)
}
}
}

mainView.logoutTouchHandler = { [weak self] in
self?.authService.logout {
self?.dismiss(animated: true)
}
}
)
}

// MARK: - AppLifeCycleDelegate -
Expand Down

0 comments on commit 4ee9995

Please sign in to comment.