Skip to content

Commit

Permalink
Resolve Code Format Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacakakpo1 committed Oct 25, 2023
1 parent e01b952 commit e809675
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*.xcworkspace/
project.xcworkspace/
xcuserdata/
DerivedData/

# Podfiles
Pods/
Expand Down
11 changes: 11 additions & 0 deletions TelnyxRTC/Telnyx/Models/Params.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ struct XHeader: Codable {
let name: String
let value: String
}

func appendCustomHeaders(customHeaders:[String:String]) -> [Any] {
var xHeaders = [Any]()
customHeaders.keys.forEach { key in
var header = [String:String]()
header["name"] = key
header["value"] = customHeaders[key]
xHeaders.append(header)
}
return xHeaders
}
14 changes: 1 addition & 13 deletions TelnyxRTC/Telnyx/TxClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,6 @@ public class TxClient {

let currentRoute = AVAudioSession.sharedInstance().currentRoute

func isSppeakerEnabled() -> Bool {
for output in currentRoute.outputs {
switch output.portType {
case AVAudioSession.Port.builtInSpeaker:
return true
default:
break
}
}
return false
}

/// Client must be registered in order to receive or place calls.
public var isRegistered: Bool {
get {
Expand Down Expand Up @@ -689,7 +677,7 @@ extension TxClient : SocketDelegate {
let callUUIDString = params["callID"] as? String,
let callUUID = UUID(uuidString: callUUIDString),
let call = calls[callUUID] {
call.handleVertoMessage(message: vertoMessage,dataMessage: message,txClient: self)
call.handleVertoMessage(message: vertoMessage, dataMessage: message, txClient: self)
}


Expand Down
9 changes: 1 addition & 8 deletions TelnyxRTC/Telnyx/Verto/AnswerMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class AnswerMessage : Message {

var params = [String: Any]()
var dialogParams = [String: Any]()
var xHeaders = [Any]()
// Merge callInfo into dialogParams
callInfo.encode().forEach { (key, value) in dialogParams[key] = value }
// Merge callOptions into dialogParams
Expand All @@ -29,13 +28,7 @@ class AnswerMessage : Message {
params["sessionId"] = sessionId
params["sdp"] = sdp
if(!customHeaders.isEmpty){
customHeaders.keys.forEach { key in
var header = [String:String]()
header["name"] = key
header["value"] = customHeaders[key]
xHeaders.append(header)
}
dialogParams["custom_headers"] = xHeaders
dialogParams["custom_headers"] = appendCustomHeaders(customHeaders: customHeaders)
}
params["dialogParams"] = dialogParams
super.init(params, method: .ANSWER)
Expand Down
9 changes: 1 addition & 8 deletions TelnyxRTC/Telnyx/Verto/InviteMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class InviteMessage : Message {
) {
var params = [String: Any]()
var dialogParams = [String: Any]()
var xHeaders = [Any]()
dialogParams["callID"] = callInfo.callId.uuidString.lowercased()
dialogParams["destination_number"] = callOptions.destinationNumber
dialogParams["remote_caller_id_name"] = callOptions.remoteCallerName
Expand All @@ -32,13 +31,7 @@ class InviteMessage : Message {
dialogParams["screenShare"] = callOptions.screenShare
dialogParams["userVariables"] = callOptions.userVariables
if(!customHeaders.isEmpty){
customHeaders.keys.forEach { key in
var header = [String:String]()
header["name"] = key
header["value"] = customHeaders[key]
xHeaders.append(header)
}
dialogParams["custom_headers"] = xHeaders
dialogParams["custom_headers"] = appendCustomHeaders(customHeaders: customHeaders)
}
if let clientState = callOptions.clientState {
dialogParams["clientState"] = clientState
Expand Down
2 changes: 1 addition & 1 deletion TelnyxRTC/Telnyx/WebRTC/Call.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ extension Call {
Logger.log.e(message: "Call:: Please enter a destination number.")
return
}
invite(callerName: callerName, callerNumber: callerNumber, destinationNumber: destinationNumber, clientState: clientState,customHeaders: customHeaders)
invite(callerName: callerName, callerNumber: callerNumber, destinationNumber: destinationNumber, clientState: clientState, customHeaders: customHeaders)
}

/// Hangup or reject an incoming call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ extension AppDelegate : CXProviderDelegate {
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
print("AppDelegate:: ANSWER call action: callKitUUID [\(String(describing: self.callKitUUID))] action [\(action.callUUID)]")

self.telnyxClient?.answerFromCallkit(answerAction: action,customHeaders: ["X-test-answer":"ios-test"])
self.telnyxClient?.answerFromCallkit(answerAction: action, customHeaders: ["X-test-answer":"ios-test"])
}

func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
Expand Down
5 changes: 3 additions & 2 deletions TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ extension ViewController : VoIPDelegate {
print("ERROR: executeCall can't be performed. Check callerName - callerNumber and destinationNumber")
return
}
let headers = ["X-test1":"ios-test1",
"X-test2":"ios-test2"]

let call = try telnyxClient?.newCall(callerName: callerName,
callerNumber: callerNumber,
destinationNumber: destinationNumber,
callId: callUUID,customHeaders: ["X-test1":"ios-test1",
"X-test2":"ios-test2"])
callId: callUUID,customHeaders: headers)
completionHandler(call)
} catch let error {
print("ViewController:: executeCall Error \(error)")
Expand Down

0 comments on commit e809675

Please sign in to comment.