From a27723753f0db602d401435f228125e37b0ee92c Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Mon, 6 Nov 2023 12:50:37 +0530 Subject: [PATCH 1/5] updated parsing --- .../live/hms/hmssdk_flutter/HMSPeerExtension.kt | 2 +- .../ios/Classes/Models/HMSPeerExtension.swift | 2 +- .../lib/src/model/hms_date_extension.dart | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt b/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt index 60dbae826..4f20cb30d 100644 --- a/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt +++ b/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt @@ -20,7 +20,7 @@ class HMSPeerExtension { args["audio_track"] = HMSTrackExtension.toDictionary(peer.audioTrack) args["video_track"] = HMSTrackExtension.toDictionary(peer.videoTrack) args["network_quality"] = HMSNetworkQualityExtension.toDictionary(peer.networkQuality) - args["joined_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(peer.joinedAt).toString() + args["joined_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(peer.joinedAt).toString() // should be seconds since epoch time val auxTrackList = ArrayList() peer.auxiliaryTracks.forEach { diff --git a/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift b/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift index 556cb731d..bd07cf1d0 100644 --- a/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift +++ b/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift @@ -19,7 +19,7 @@ class HMSPeerExtension { "is_hand_raised": peer.isHandRaised, "customer_description": peer.metadata ?? "", "customer_user_id": peer.customerUserID ?? "", - "joined_at": "\(peer.joinedAt)", + "joined_at": "\(peer.joinedAt.timeIntervalSince1970)", "updated_at": "\(peer.updatedAt)" ] as [String: Any] diff --git a/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart b/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart index 0e9a423f1..830f66ac1 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart @@ -3,8 +3,13 @@ ///[HMSDateExtension] is used to convert android and ios native time format to DateTime type ///in local time zone format. class HMSDateExtension { - static DateTime convertDate(String date) { - DateTime _dateTime = DateTime.parse(date).toLocal(); - return _dateTime; + static DateTime? convertDate(String date) { + try { + DateTime _dateTime = DateTime.parse(date).toLocal(); + return _dateTime; + } catch (e) { + print(e); + } + return null; } } From b520205a64bce10a456ecae1a9279265f31fb82f Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Mon, 6 Nov 2023 16:20:43 +0530 Subject: [PATCH 2/5] Added date time handling for android --- packages/hms_room_kit/example/pubspec.lock | 9 ++++---- packages/hms_room_kit/pubspec.lock | 9 ++++---- packages/hms_room_kit/pubspec.yaml | 3 ++- .../hms/hmssdk_flutter/HMSPeerExtension.kt | 2 +- .../hmssdk_flutter/example/ios/Podfile.lock | 12 +++++------ packages/hmssdk_flutter/example/pubspec.lock | 9 ++++---- .../ios/Classes/Models/HMSPeerExtension.swift | 4 ++-- .../lib/src/model/hms_date_extension.dart | 12 +++++++++-- .../lib/src/model/hms_local_peer.dart | 4 ++-- .../lib/src/model/hms_peer.dart | 21 +------------------ 10 files changed, 36 insertions(+), 49 deletions(-) diff --git a/packages/hms_room_kit/example/pubspec.lock b/packages/hms_room_kit/example/pubspec.lock index 455b8c191..5edf2abf8 100644 --- a/packages/hms_room_kit/example/pubspec.lock +++ b/packages/hms_room_kit/example/pubspec.lock @@ -226,11 +226,10 @@ packages: hmssdk_flutter: dependency: transitive description: - name: hmssdk_flutter - sha256: "370556fc44ccb950508f9ec67a47285fd901fc2ecce7d0008f0a25e8bbd08389" - url: "https://pub.dev" - source: hosted - version: "1.9.1" + path: "../../hmssdk_flutter" + relative: true + source: path + version: "1.9.2" http: dependency: transitive description: diff --git a/packages/hms_room_kit/pubspec.lock b/packages/hms_room_kit/pubspec.lock index 59e3bfb1b..d09df5623 100644 --- a/packages/hms_room_kit/pubspec.lock +++ b/packages/hms_room_kit/pubspec.lock @@ -211,11 +211,10 @@ packages: hmssdk_flutter: dependency: "direct main" description: - name: hmssdk_flutter - sha256: "370556fc44ccb950508f9ec67a47285fd901fc2ecce7d0008f0a25e8bbd08389" - url: "https://pub.dev" - source: hosted - version: "1.9.1" + path: "../hmssdk_flutter" + relative: true + source: path + version: "1.9.2" http: dependency: transitive description: diff --git a/packages/hms_room_kit/pubspec.yaml b/packages/hms_room_kit/pubspec.yaml index e60f9f614..be93dd171 100644 --- a/packages/hms_room_kit/pubspec.yaml +++ b/packages/hms_room_kit/pubspec.yaml @@ -14,7 +14,8 @@ dependencies: flutter: sdk: flutter - hmssdk_flutter: ^1.9.1 + hmssdk_flutter: + path: ../hmssdk_flutter intl: ^0.18.1 permission_handler: ^11.0.0 provider: ^6.0.5 diff --git a/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt b/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt index 4f20cb30d..a508cc3a9 100644 --- a/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt +++ b/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt @@ -20,7 +20,7 @@ class HMSPeerExtension { args["audio_track"] = HMSTrackExtension.toDictionary(peer.audioTrack) args["video_track"] = HMSTrackExtension.toDictionary(peer.videoTrack) args["network_quality"] = HMSNetworkQualityExtension.toDictionary(peer.networkQuality) - args["joined_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(peer.joinedAt).toString() // should be seconds since epoch time + args["joined_at"] = peer.joinedAt // should be seconds since epoch time val auxTrackList = ArrayList() peer.auxiliaryTracks.forEach { diff --git a/packages/hmssdk_flutter/example/ios/Podfile.lock b/packages/hmssdk_flutter/example/ios/Podfile.lock index ff9ae946b..d0b5acc72 100644 --- a/packages/hmssdk_flutter/example/ios/Podfile.lock +++ b/packages/hmssdk_flutter/example/ios/Podfile.lock @@ -97,14 +97,14 @@ PODS: - HMSBroadcastExtensionSDK (0.0.9) - HMSHLSPlayerSDK (0.0.2): - HMSAnalyticsSDK (= 0.0.2) - - HMSSDK (1.1.0): + - HMSSDK (1.2.0): - HMSAnalyticsSDK (= 0.0.2) - HMSWebRTC (= 1.0.5116) - - hmssdk_flutter (1.9.1): + - hmssdk_flutter (1.9.2): - Flutter - HMSBroadcastExtensionSDK (= 0.0.9) - HMSHLSPlayerSDK (= 0.0.2) - - HMSSDK (= 1.1.0) + - HMSSDK (= 1.2.0) - HMSWebRTC (1.0.5116) - MTBBarcodeScanner (5.0.11) - nanopb (2.30909.1): @@ -235,8 +235,8 @@ SPEC CHECKSUMS: HMSAnalyticsSDK: 4d2a88a729b1eb42f3d25f217c28937ec318a5b7 HMSBroadcastExtensionSDK: d80fe325f6c928bd8e5176290b5a4b7ae15d6fbb HMSHLSPlayerSDK: 6a54ad4d12f3dc2270d1ecd24019d71282a4f6a3 - HMSSDK: 49e3ac665ceb8904d41787ddf99742e8d7d6529a - hmssdk_flutter: 6c69bfe89445350e9cd8d1c37a72808aedfbdf02 + HMSSDK: 010fdd904b8d221bb297864800503132fd721d9e + hmssdk_flutter: 1d4cfbb745095ebf399eaf533b6cde0c2006d6e1 HMSWebRTC: ae54e9dd91b869051b283b43b14f57d43b7bf8e1 MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5 @@ -253,4 +253,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 919064996fff867cd85dbf9e7730ff45bac23884 -COCOAPODS: 1.14.2 +COCOAPODS: 1.13.0 diff --git a/packages/hmssdk_flutter/example/pubspec.lock b/packages/hmssdk_flutter/example/pubspec.lock index 799ca3d6a..b3df1103a 100644 --- a/packages/hmssdk_flutter/example/pubspec.lock +++ b/packages/hmssdk_flutter/example/pubspec.lock @@ -298,11 +298,10 @@ packages: hmssdk_flutter: dependency: transitive description: - name: hmssdk_flutter - sha256: "370556fc44ccb950508f9ec67a47285fd901fc2ecce7d0008f0a25e8bbd08389" - url: "https://pub.dev" - source: hosted - version: "1.9.1" + path: ".." + relative: true + source: path + version: "1.9.2" http: dependency: transitive description: diff --git a/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift b/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift index bd07cf1d0..dffeb3be8 100644 --- a/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift +++ b/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift @@ -19,8 +19,8 @@ class HMSPeerExtension { "is_hand_raised": peer.isHandRaised, "customer_description": peer.metadata ?? "", "customer_user_id": peer.customerUserID ?? "", - "joined_at": "\(peer.joinedAt.timeIntervalSince1970)", - "updated_at": "\(peer.updatedAt)" + "joined_at": peer.joinedAt.timeIntervalSince1970, + "updated_at": peer.updatedAt.timeIntervalSince1970 ] as [String: Any] if let metadata = peer.metadata { diff --git a/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart b/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart index 830f66ac1..b8877d75f 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart @@ -1,11 +1,19 @@ +import 'dart:developer'; + ///100ms HMSDateExtension /// ///[HMSDateExtension] is used to convert android and ios native time format to DateTime type ///in local time zone format. class HMSDateExtension { - static DateTime? convertDate(String date) { + static DateTime convertDate(int date) { + DateTime _dateTime = DateTime.fromMillisecondsSinceEpoch(date); + return _dateTime; + } + + static optionalConvertDate(int date) { try { - DateTime _dateTime = DateTime.parse(date).toLocal(); + DateTime _dateTime = DateTime.fromMillisecondsSinceEpoch(date); + // DateTime _dateTime = DateTime.parse(date).toLocal(); return _dateTime; } catch (e) { print(e); diff --git a/packages/hmssdk_flutter/lib/src/model/hms_local_peer.dart b/packages/hmssdk_flutter/lib/src/model/hms_local_peer.dart index 0f7276c25..2d78ddc45 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_local_peer.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_local_peer.dart @@ -62,10 +62,10 @@ class HMSLocalPeer extends HMSPeer { ? HMSNetworkQuality.fromMap(map["network_quality"]) : null, joinedAt: map.containsKey("joined_at") - ? HMSDateExtension.convertDate(map["joined_at"]) + ? HMSDateExtension.optionalConvertDate(map["joined_at"].toInt()) : null, updatedAt: map.containsKey("updated_at") - ? HMSDateExtension.convertDate(map["updated_at"]) + ? HMSDateExtension.optionalConvertDate(map["updated_at"]) : null, ); } diff --git a/packages/hmssdk_flutter/lib/src/model/hms_peer.dart b/packages/hmssdk_flutter/lib/src/model/hms_peer.dart index 0fa5c7719..350256fb9 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_peer.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_peer.dart @@ -85,26 +85,7 @@ class HMSPeer { // TODO: add auxiliary tracks HMSPeer peer = (map['is_local'] == true) - ? HMSLocalPeer( - peerId: map['peer_id'], - name: map['name'], - isLocal: map['is_local'], - isHandRaised: map['is_hand_raised'], - role: role, - metadata: map['metadata'], - customerUserId: map['customer_user_id'], - networkQuality: map['network_quality'] == null - ? null - : HMSNetworkQuality.fromMap( - map['network_quality'], - ), - joinedAt: map.containsKey("joined_at") - ? HMSDateExtension.convertDate(map["joined_at"]) - : null, - updatedAt: map.containsKey("updated_at") - ? HMSDateExtension.convertDate(map["updated_at"]) - : null, - ) + ? HMSLocalPeer.fromMap(map) : HMSRemotePeer( peerId: map['peer_id'], name: map['name'], From c913bf64f57dda39a99018d725d9087c5b4a843b Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Tue, 7 Nov 2023 17:26:45 +0530 Subject: [PATCH 3/5] Fixed datetime bug --- .../ios/Classes/Models/HMSPeerExtension.swift | 4 ++-- .../lib/src/model/hls_player/hms_hls_cue.dart | 4 ++-- .../src/model/hms_browser_recording_state.dart | 2 +- .../lib/src/model/hms_date_extension.dart | 15 +++++++++------ .../lib/src/model/hms_hls_recording_state.dart | 2 +- .../lib/src/model/hms_hls_variant.dart | 2 +- .../lib/src/model/hms_local_peer.dart | 4 ++-- .../hmssdk_flutter/lib/src/model/hms_message.dart | 2 +- .../lib/src/model/hms_remote_peer.dart | 5 ++--- .../lib/src/model/hms_rtmp_streaming_state.dart | 2 +- .../lib/src/model/hms_server_recording_state.dart | 2 +- 11 files changed, 23 insertions(+), 21 deletions(-) diff --git a/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift b/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift index dffeb3be8..8e84988de 100644 --- a/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift +++ b/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift @@ -19,8 +19,8 @@ class HMSPeerExtension { "is_hand_raised": peer.isHandRaised, "customer_description": peer.metadata ?? "", "customer_user_id": peer.customerUserID ?? "", - "joined_at": peer.joinedAt.timeIntervalSince1970, - "updated_at": peer.updatedAt.timeIntervalSince1970 + "joined_at": Int(peer.joinedAt.timeIntervalSince1970)*1000, + "updated_at": Int(peer.updatedAt.timeIntervalSince1970)*1000 ] as [String: Any] if let metadata = peer.metadata { diff --git a/packages/hmssdk_flutter/lib/src/model/hls_player/hms_hls_cue.dart b/packages/hmssdk_flutter/lib/src/model/hls_player/hms_hls_cue.dart index c007ef9b9..1ffd1408f 100644 --- a/packages/hmssdk_flutter/lib/src/model/hls_player/hms_hls_cue.dart +++ b/packages/hmssdk_flutter/lib/src/model/hls_player/hms_hls_cue.dart @@ -22,10 +22,10 @@ class HMSHLSCue { factory HMSHLSCue.fromMap(Map map) { return HMSHLSCue( - startDate: HMSDateExtension.convertDate(map["start_date"]), + startDate: HMSDateExtension.convertDateFromString(map["start_date"]), endDate: map["end_date"] == null ? null - : HMSDateExtension.convertDate(map["end_date"]), + : HMSDateExtension.convertDateFromString(map["end_date"]), id: map["id"], payload: map["payload"]); } diff --git a/packages/hmssdk_flutter/lib/src/model/hms_browser_recording_state.dart b/packages/hmssdk_flutter/lib/src/model/hms_browser_recording_state.dart index b67463262..eab39848f 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_browser_recording_state.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_browser_recording_state.dart @@ -21,7 +21,7 @@ class HMSBrowserRecordingState { error: map["error"] != null ? HMSException.fromMap(map) : null, running: map['running'], startedAt: map['started_at'] != null - ? HMSDateExtension.convertDate(map['started_at']) + ? HMSDateExtension.convertDateFromString(map['started_at']) : null, initialising: map['initialising']); } diff --git a/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart b/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart index b8877d75f..cd1e7c331 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart @@ -5,18 +5,21 @@ import 'dart:developer'; ///[HMSDateExtension] is used to convert android and ios native time format to DateTime type ///in local time zone format. class HMSDateExtension { - static DateTime convertDate(int date) { - DateTime _dateTime = DateTime.fromMillisecondsSinceEpoch(date); + + ///Returns DateTime object from String + static DateTime convertDateFromString(String date) { + DateTime _dateTime = DateTime.parse(date).toLocal(); return _dateTime; } - static optionalConvertDate(int date) { + ///Returns optional DateTime object from epoch in milliseconds + static DateTime? convertDateFromEpoch(int date) { try { - DateTime _dateTime = DateTime.fromMillisecondsSinceEpoch(date); - // DateTime _dateTime = DateTime.parse(date).toLocal(); + DateTime _dateTime = + DateTime.fromMillisecondsSinceEpoch(date, isUtc: false); return _dateTime; } catch (e) { - print(e); + log(e.toString()); } return null; } diff --git a/packages/hmssdk_flutter/lib/src/model/hms_hls_recording_state.dart b/packages/hmssdk_flutter/lib/src/model/hms_hls_recording_state.dart index a82e01fe5..840647dca 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_hls_recording_state.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_hls_recording_state.dart @@ -19,7 +19,7 @@ class HMSHLSRecordingState { : null, running: map['running'], startedAt: map['started_at'] != null - ? HMSDateExtension.convertDate(map['started_at']) + ? HMSDateExtension.convertDateFromString(map['started_at']) : null); } } diff --git a/packages/hmssdk_flutter/lib/src/model/hms_hls_variant.dart b/packages/hmssdk_flutter/lib/src/model/hms_hls_variant.dart index 44a0bd4ae..d875b9f06 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_hls_variant.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_hls_variant.dart @@ -38,7 +38,7 @@ class HMSHLSVariant { meetingUrl: map['meeting_url'] as String?, metadata: map['metadata'] as String?, startedAt: map['started_at'] != null - ? HMSDateExtension.convertDate(map['started_at']) + ? HMSDateExtension.convertDateFromString(map['started_at']) : null, ); } diff --git a/packages/hmssdk_flutter/lib/src/model/hms_local_peer.dart b/packages/hmssdk_flutter/lib/src/model/hms_local_peer.dart index 2d78ddc45..59957cf29 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_local_peer.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_local_peer.dart @@ -62,10 +62,10 @@ class HMSLocalPeer extends HMSPeer { ? HMSNetworkQuality.fromMap(map["network_quality"]) : null, joinedAt: map.containsKey("joined_at") - ? HMSDateExtension.optionalConvertDate(map["joined_at"].toInt()) + ? HMSDateExtension.convertDateFromEpoch(map["joined_at"]) : null, updatedAt: map.containsKey("updated_at") - ? HMSDateExtension.optionalConvertDate(map["updated_at"]) + ? HMSDateExtension.convertDateFromEpoch(map["updated_at"]) : null, ); } diff --git a/packages/hmssdk_flutter/lib/src/model/hms_message.dart b/packages/hmssdk_flutter/lib/src/model/hms_message.dart index 4cb69fb37..a7093063b 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_message.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_message.dart @@ -56,7 +56,7 @@ class HMSMessage { sender: sender, message: messageMap['message'] as String, type: messageMap['type'] as String, - time: HMSDateExtension.convertDate(messageMap['time']), + time: HMSDateExtension.convertDateFromString(messageMap['time']), hmsMessageRecipient: recipient); } diff --git a/packages/hmssdk_flutter/lib/src/model/hms_remote_peer.dart b/packages/hmssdk_flutter/lib/src/model/hms_remote_peer.dart index 8f22b400b..b820c6f0b 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_remote_peer.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_remote_peer.dart @@ -63,7 +63,6 @@ class HMSRemotePeer extends HMSPeer { factory HMSRemotePeer.fromMap(Map map) { HMSRole role = HMSRole.fromMap(map['role']); - // TODO: add auxiliary tracks HMSRemotePeer peer = HMSRemotePeer( peerId: map['peer_id'], name: map['name'], @@ -76,10 +75,10 @@ class HMSRemotePeer extends HMSPeer { ? HMSNetworkQuality.fromMap(map["network_quality"]) : null, joinedAt: map.containsKey("joined_at") - ? HMSDateExtension.convertDate(map["joined_at"]) + ? HMSDateExtension.convertDateFromEpoch(map["joined_at"]) : null, updatedAt: map.containsKey("updated_at") - ? HMSDateExtension.convertDate(map["updated_at"]) + ? HMSDateExtension.convertDateFromEpoch(map["updated_at"]) : null, ); diff --git a/packages/hmssdk_flutter/lib/src/model/hms_rtmp_streaming_state.dart b/packages/hmssdk_flutter/lib/src/model/hms_rtmp_streaming_state.dart index 6b3d72baf..65b46dc8e 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_rtmp_streaming_state.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_rtmp_streaming_state.dart @@ -17,7 +17,7 @@ class HMSRtmpStreamingState { error: map["error"] != null ? HMSException.fromMap(map) : null, running: map['running'], startedAt: map['started_at'] != null - ? HMSDateExtension.convertDate(map['started_at']) + ? HMSDateExtension.convertDateFromString(map['started_at']) : null); } } diff --git a/packages/hmssdk_flutter/lib/src/model/hms_server_recording_state.dart b/packages/hmssdk_flutter/lib/src/model/hms_server_recording_state.dart index fe051c427..127bd0c24 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_server_recording_state.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_server_recording_state.dart @@ -18,7 +18,7 @@ class HMSServerRecordingState { error: map["error"] != null ? HMSException.fromMap(map) : null, running: map['running'], startedAt: map['started_at'] != null - ? HMSDateExtension.convertDate(map['started_at']) + ? HMSDateExtension.convertDateFromString(map['started_at']) : null); } } From 1bf420165bfbdf08b39a3dfe475afbd27c897237 Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Tue, 7 Nov 2023 17:27:00 +0530 Subject: [PATCH 4/5] Update HMSPeer object --- .../lib/src/model/hms_peer.dart | 37 +------------------ 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/packages/hmssdk_flutter/lib/src/model/hms_peer.dart b/packages/hmssdk_flutter/lib/src/model/hms_peer.dart index 350256fb9..76ffb8ff1 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_peer.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_peer.dart @@ -80,42 +80,9 @@ class HMSPeer { int get hashCode => peerId.hashCode; factory HMSPeer.fromMap(Map map) { - HMSRole role = HMSRole.fromMap(map['role']); - - // TODO: add auxiliary tracks - - HMSPeer peer = (map['is_local'] == true) + return (map['is_local'] == true) ? HMSLocalPeer.fromMap(map) - : HMSRemotePeer( - peerId: map['peer_id'], - name: map['name'], - isLocal: map['is_local'], - isHandRaised: map['is_hand_raised'], - role: role, - metadata: map['metadata'], - customerUserId: map['customer_user_id'], - networkQuality: map['network_quality'] == null - ? null - : HMSNetworkQuality.fromMap(map['network_quality']), - joinedAt: map.containsKey("joined_at") - ? HMSDateExtension.convertDate(map["joined_at"]) - : null, - updatedAt: map.containsKey("updated_at") - ? HMSDateExtension.convertDate(map["updated_at"]) - : null, - ); - - if (map['audio_track'] != null) { - peer.audioTrack = HMSAudioTrack.fromMap( - map: map['audio_track']!, isLocal: peer.isLocal); - } - - if (map['video_track'] != null) { - peer.videoTrack = HMSVideoTrack.fromMap( - map: map['video_track']!, isLocal: peer.isLocal); - } - - return peer; + : HMSRemotePeer.fromMap(map); } @override From 51cfdf8a6bd8e940416d1e2cb3c93682f9366540 Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Tue, 7 Nov 2023 18:56:50 +0530 Subject: [PATCH 5/5] Added suggested changes --- .../kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt | 2 +- .../ios/Classes/Models/HMSPeerExtension.swift | 4 ++-- .../hmssdk_flutter/lib/src/model/hms_date_extension.dart | 7 ++++--- packages/hmssdk_flutter/lib/src/model/hms_peer.dart | 1 - 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt b/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt index a508cc3a9..68ad7efb6 100644 --- a/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt +++ b/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSPeerExtension.kt @@ -20,7 +20,7 @@ class HMSPeerExtension { args["audio_track"] = HMSTrackExtension.toDictionary(peer.audioTrack) args["video_track"] = HMSTrackExtension.toDictionary(peer.videoTrack) args["network_quality"] = HMSNetworkQualityExtension.toDictionary(peer.networkQuality) - args["joined_at"] = peer.joinedAt // should be seconds since epoch time + args["joined_at"] = peer.joinedAt val auxTrackList = ArrayList() peer.auxiliaryTracks.forEach { diff --git a/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift b/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift index 8e84988de..873ddf980 100644 --- a/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift +++ b/packages/hmssdk_flutter/ios/Classes/Models/HMSPeerExtension.swift @@ -19,8 +19,8 @@ class HMSPeerExtension { "is_hand_raised": peer.isHandRaised, "customer_description": peer.metadata ?? "", "customer_user_id": peer.customerUserID ?? "", - "joined_at": Int(peer.joinedAt.timeIntervalSince1970)*1000, - "updated_at": Int(peer.updatedAt.timeIntervalSince1970)*1000 + "joined_at": Int(peer.joinedAt.timeIntervalSince1970 * 1000), + "updated_at": Int(peer.updatedAt.timeIntervalSince1970 * 1000) ] as [String: Any] if let metadata = peer.metadata { diff --git a/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart b/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart index cd1e7c331..caf3f96c0 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart @@ -1,11 +1,12 @@ -import 'dart:developer'; - ///100ms HMSDateExtension /// ///[HMSDateExtension] is used to convert android and ios native time format to DateTime type ///in local time zone format. -class HMSDateExtension { +///Dart imports +import 'dart:developer'; + +class HMSDateExtension { ///Returns DateTime object from String static DateTime convertDateFromString(String date) { DateTime _dateTime = DateTime.parse(date).toLocal(); diff --git a/packages/hmssdk_flutter/lib/src/model/hms_peer.dart b/packages/hmssdk_flutter/lib/src/model/hms_peer.dart index 76ffb8ff1..d1eb9a1ac 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_peer.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_peer.dart @@ -1,6 +1,5 @@ // Project imports: import 'package:hmssdk_flutter/hmssdk_flutter.dart'; -import 'package:hmssdk_flutter/src/model/hms_date_extension.dart'; import 'package:hmssdk_flutter/src/service/platform_service.dart'; ///100ms HMSPeer.