From 31e481a649574fede698298bac68e1c01a10449a Mon Sep 17 00:00:00 2001 From: incubo4u Date: Fri, 12 Jan 2024 12:38:43 +0100 Subject: [PATCH] Incubo4u/fix-endpoints-metadata (#51) --- Sources/MembraneRTC/Events/Event.swift | 14 +++++++------- Sources/MembraneRTC/RTCEngineCommunication.swift | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Sources/MembraneRTC/Events/Event.swift b/Sources/MembraneRTC/Events/Event.swift index b439c3f4..854bea92 100644 --- a/Sources/MembraneRTC/Events/Event.swift +++ b/Sources/MembraneRTC/Events/Event.swift @@ -183,7 +183,7 @@ public enum Events { Sendable events */ struct ConnectEvent: SendableEvent { - let metadata: Metadata + let metadata: Metadata? func serialize() -> Payload { return .init([ @@ -195,7 +195,7 @@ struct ConnectEvent: SendableEvent { struct SdpOfferEvent: SendableEvent { let sdp: String - let trackIdToTrackMetadata: [String: Metadata] + let trackIdToTrackMetadata: [String: Metadata?] let midToTrackId: [String: String] func serialize() -> Payload { @@ -264,7 +264,7 @@ struct SelectEncodingEvent: SendableEvent { } struct UpdateEndpointMetadata: SendableEvent { - let metadata: Metadata + let metadata: Metadata? func serialize() -> Payload { return .init([ @@ -276,7 +276,7 @@ struct UpdateEndpointMetadata: SendableEvent { struct UpdateTrackMetadata: SendableEvent { let trackId: String - let trackMetadata: Metadata + let trackMetadata: Metadata? func serialize() -> Payload { return .init([ @@ -304,7 +304,7 @@ struct EndpointAddedEvent: ReceivableEvent, Codable { struct Data: Codable { let id: String let type: String - let metadata: Metadata + let metadata: Metadata? let trackIdToMetadata: [String: Metadata]? } @@ -324,7 +324,7 @@ struct EndpointRemovedEvent: ReceivableEvent, Codable { struct EndpointUpdatedEvent: ReceivableEvent, Codable { struct Data: Codable { let endpointId: String - let metadata: Metadata + let metadata: Metadata? } let type: ReceivableEventType @@ -373,7 +373,7 @@ struct TracksUpdatedEvent: ReceivableEvent, Codable { struct Data: Codable { let endpointId: String let trackId: String - let metadata: Metadata + let metadata: Metadata? } let type: ReceivableEventType diff --git a/Sources/MembraneRTC/RTCEngineCommunication.swift b/Sources/MembraneRTC/RTCEngineCommunication.swift index 26c9f7c0..20da46f6 100644 --- a/Sources/MembraneRTC/RTCEngineCommunication.swift +++ b/Sources/MembraneRTC/RTCEngineCommunication.swift @@ -67,7 +67,7 @@ internal class RTCEngineCommunication { case .EndpointUpdated: let endpointUpdated = event as! EndpointUpdatedEvent engineListener.onEndpointUpdated( - endpointId: endpointUpdated.data.endpointId, metadata: endpointUpdated.data.metadata) + endpointId: endpointUpdated.data.endpointId, metadata: endpointUpdated.data.metadata ?? AnyJson()) case .OfferData: let offerData = event as! OfferDataEvent engineListener.onOfferData( @@ -89,7 +89,7 @@ internal class RTCEngineCommunication { let tracksUpdated = event as! TracksUpdatedEvent engineListener.onTrackUpdated( endpointId: tracksUpdated.data.endpointId, trackId: tracksUpdated.data.trackId, - metadata: tracksUpdated.data.metadata) + metadata: tracksUpdated.data.metadata ?? AnyJson()) case .SdpAnswer: let sdpAnswer = event as! SdpAnswerEvent engineListener.onSdpAnswer(