Skip to content

Commit

Permalink
(InAppScreenSharing) 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 28faccd commit 8f056d8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 47 deletions.
5 changes: 2 additions & 3 deletions InAppScreenSharing/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ fileprivate let callManager: CallManager = CallManager(client, authService)
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 { "InAppScreenSharing" }

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

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Expand Down
18 changes: 10 additions & 8 deletions InAppScreenSharing/Stories/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ 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,12 +22,16 @@ 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 InAppScreenSharing/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)
}
}
)
}

override func viewWillAppear(_ animated: Bool) {
Expand Down

0 comments on commit 8f056d8

Please sign in to comment.