From 830dd736c826b7dd950b2e971bf2540e027123ae Mon Sep 17 00:00:00 2001 From: Isaac <134492608+isaacakakpo1@users.noreply.github.com> Date: Mon, 26 Aug 2024 09:56:36 +0000 Subject: [PATCH] Client Logs CleanUp --- .gitignore | 12 +++++ .idea/libraries/Flutter_Plugins.xml | 52 +++++++++---------- android/.idea/.gitignore | 3 ++ lib/main.dart | 1 + lib/main_view_model.dart | 2 - packages/telnyx_webrtc/lib/call.dart | 10 ++-- packages/telnyx_webrtc/lib/telnyx_client.dart | 11 ++-- packages/telnyx_webrtc/lib/tx_socket.dart | 2 +- packages/telnyx_webrtc/pubspec.yaml | 2 +- 9 files changed, 54 insertions(+), 41 deletions(-) create mode 100644 android/.idea/.gitignore diff --git a/.gitignore b/.gitignore index 5ac5838..4d9da06 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,15 @@ lib/generated_plugin_registrant.dart android/app/google-services.json .idea/libraries/Dart_SDK.xml .idea/libraries/Flutter_Plugins.xml +.idea/other.xml +.idea/libraries/Flutter_Plugins.xml +android/.idea/appInsightsSettings.xml +android/.idea/compiler.xml +android/.idea/deploymentTargetSelector.xml +android/.idea/gradle.xml +android/.idea/kotlinc.xml +android/.idea/migrations.xml +android/.idea/misc.xml +android/.idea/other.xml +android/.idea/vcs.xml +android/app/lint-baseline.xml diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml index 768645a..007b081 100644 --- a/.idea/libraries/Flutter_Plugins.xml +++ b/.idea/libraries/Flutter_Plugins.xml @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/.idea/.gitignore b/android/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/android/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/lib/main.dart b/lib/main.dart index a3cc0ad..d34ffa3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -62,6 +62,7 @@ Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { case SocketMethod.BYE: { //make sure to disconnect the telnyxclient on Bye for Decline + // Only disconnect the socket when the call was ended from push notifications print("telnyxClient disconnected"); telnyxClient.disconnect(); break; diff --git a/lib/main_view_model.dart b/lib/main_view_model.dart index 447d99d..e09414a 100644 --- a/lib/main_view_model.dart +++ b/lib/main_view_model.dart @@ -210,8 +210,6 @@ class MainViewModel with ChangeNotifier { } void call(String destination) { - _telnyxClient.txSocket.close(); - if (!_telnyxClient.isConnected()) {} _currentCall = _telnyxClient.newInvite( _localName, _localNumber, destination, "Fake State", customHeaders: {"X-Header-1": "Value1", "X-Header-2": "Value2"}); diff --git a/packages/telnyx_webrtc/lib/call.dart b/packages/telnyx_webrtc/lib/call.dart index 8b139a7..1f92fa0 100644 --- a/packages/telnyx_webrtc/lib/call.dart +++ b/packages/telnyx_webrtc/lib/call.dart @@ -39,7 +39,7 @@ class CallHandler { /// The Call class which is used for call related methods such as hold/mute or /// creating invitations, declining calls, etc. class Call { - Call(this._txSocket, this._txClient, this.sessid, this.ringToneFile, + Call(this.txSocket, this._txClient, this.sessid, this.ringToneFile, this.ringBackFile, this.callHandler, this.callEnded); late CallHandler callHandler; @@ -48,7 +48,7 @@ class Call { final audioService = AudioService(); final mobileAudioPlayer = AssetsAudioPlayer.newPlayer(); final Function callEnded; - final TxSocket _txSocket; + final TxSocket txSocket; final TelnyxClient _txClient; final String sessid; final String ringBackFile; @@ -123,7 +123,7 @@ class Call { _logger.d("Session end peer connection null"); } - _txSocket.send(jsonByeMessage); + txSocket.send(jsonByeMessage); if (peerConnection != null) { peerConnection?.closeSession(); } else { @@ -167,7 +167,7 @@ class Call { params: infoParams); String jsonDtmfMessage = jsonEncode(dtmfMessageBody); - _txSocket.send(jsonDtmfMessage); + txSocket.send(jsonDtmfMessage); } /// Either mutes or unmutes local audio based on the current mute state @@ -219,7 +219,7 @@ class Call { jsonrpc: JsonRPCConstant.jsonrpc); String jsonModifyMessage = jsonEncode(modifyMessage); - _txSocket.send(jsonModifyMessage); + txSocket.send(jsonModifyMessage); } // Example file path for 'web/assets/audio/sound.wav' diff --git a/packages/telnyx_webrtc/lib/telnyx_client.dart b/packages/telnyx_webrtc/lib/telnyx_client.dart index 05cdbb8..f15b8eb 100644 --- a/packages/telnyx_webrtc/lib/telnyx_client.dart +++ b/packages/telnyx_webrtc/lib/telnyx_client.dart @@ -252,7 +252,7 @@ class TelnyxClient { try { if (_pushMetaData != null) { txSocket.hostAddress = - "$_storedHostAddress?voice_sdk_id=${_pushMetaData?.voice_sdk_id}"; + "$_storedHostAddress?voice_sdk_id=${_pushMetaData?.voice_sdk_id}"; _logger.i( 'Connecting to WebSocket with voice_sdk_id :: ${_pushMetaData?.voice_sdk_id}'); print("Connecting to WebSocket :: ${txSocket.hostAddress}"); @@ -288,11 +288,10 @@ class TelnyxClient { void connectWithCredential(CredentialConfig credentialConfig) { _logger.i('connect()'); - _logger.i('connecting to WebSocket $_storedHostAddress'); try { if (_pushMetaData != null) { txSocket.hostAddress = - "$_storedHostAddress?voice_sdk_id=${_pushMetaData?.voice_sdk_id}"; + "$_storedHostAddress?voice_sdk_id=${_pushMetaData?.voice_sdk_id}"; _logger.i( 'Connecting to WebSocket with voice_sdk_id :: ${_pushMetaData?.voice_sdk_id}'); print("Connecting to WebSocket :: ${txSocket.hostAddress}"); @@ -326,8 +325,8 @@ class TelnyxClient { } } - - @Deprecated("Use connect with token or credential login i.e connectWithCredential(..) or connectWithToken(..)") + @Deprecated( + "Use connect with token or credential login i.e connectWithCredential(..) or connectWithToken(..)") void connect() { _logger.i('connect()'); if (isConnected()) { @@ -528,7 +527,7 @@ class TelnyxClient { var base64State = base64.encode(utf8.encode(clientState)); updateCall(inviteCall); - inviteCall.peerConnection = Peer(txSocket); + inviteCall.peerConnection = Peer(inviteCall.txSocket); inviteCall.peerConnection?.invite( callerName, callerNumber, diff --git a/packages/telnyx_webrtc/lib/tx_socket.dart b/packages/telnyx_webrtc/lib/tx_socket.dart index 087a4d8..e07fb93 100644 --- a/packages/telnyx_webrtc/lib/tx_socket.dart +++ b/packages/telnyx_webrtc/lib/tx_socket.dart @@ -19,8 +19,8 @@ class TxSocket { void connect() async { try { print("TxSocket :: connect : $hostAddress"); + _socket = await WebSocket.connect(hostAddress); - _logger.i('Connecting to $hostAddress'); _socket.pingInterval = const Duration(seconds: 10); _socket.timeout(const Duration(seconds: 30)); onOpen.call(); diff --git a/packages/telnyx_webrtc/pubspec.yaml b/packages/telnyx_webrtc/pubspec.yaml index b36fa2e..8bde5b9 100644 --- a/packages/telnyx_webrtc/pubspec.yaml +++ b/packages/telnyx_webrtc/pubspec.yaml @@ -3,7 +3,7 @@ description: Enable real-time communication with WebRTC and Telnyx. Create and r homepage: https://telnyx.com/ repository: https://github.com/team-telnyx/flutter-voice-sdk issue_tracker: https://github.com/team-telnyx/flutter-voice-sdk/issues?q=is%3Aopen+is%3Aissue -version: 0.0.16 +version: 0.0.17 environment: sdk: ">=3.0.0 <3.22.3"