Skip to content

Commit

Permalink
Generated code for participant count session event (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmitrevski authored Aug 26, 2024
1 parent 03c3a30 commit 0e8e550
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Sources/StreamVideo/CallState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ public class CallState: ObservableObject {
break
case .typeCallUserMutedEvent:
break
case .typeCallRtmpBroadcastFailedEvent:
break
case .typeCallSessionParticipantCountsUpdatedEvent:
break
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// CallRtmpBroadcastFailedEvent.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation
/** This event is sent when a call RTMP broadcast has failed */

public struct CallRtmpBroadcastFailedEvent: @unchecked Sendable, Event, Codable, JSONEncodable, Hashable, WSCallEvent {
/** The unique identifier for a call (<type>:<id>) */
public var callCid: String
/** Date/time of creation */
public var createdAt: Date
/** Name of the given RTMP broadcast */
public var name: String
/** The type of event: \"call.rtmp_broadcast_failed\" in this case */
public var type: String = "call.rtmp_broadcast_failed"

public init(callCid: String, createdAt: Date, name: String, type: String = "call.rtmp_broadcast_failed") {
self.callCid = callCid
self.createdAt = createdAt
self.name = name
self.type = type
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case callCid = "call_cid"
case createdAt = "created_at"
case name
case type
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(callCid, forKey: .callCid)
try container.encode(createdAt, forKey: .createdAt)
try container.encode(name, forKey: .name)
try container.encode(type, forKey: .type)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// CallSessionParticipantCountsUpdatedEvent.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation
/** This event is sent when the participant counts in a call session are updated */

public struct CallSessionParticipantCountsUpdatedEvent: @unchecked Sendable, Event, Codable, JSONEncodable, Hashable, WSCallEvent {
public var anonymousParticipantCount: Int
public var callCid: String
public var createdAt: Date
public var participantsCountByRole: [String: Int]
/** Call session ID */
public var sessionId: String
/** The type of event: \"call.session_participant_count_updated\" in this case */
public var type: String = "call.session_participant_count_updated"

public init(anonymousParticipantCount: Int, callCid: String, createdAt: Date, participantsCountByRole: [String: Int], sessionId: String, type: String = "call.session_participant_count_updated") {
self.anonymousParticipantCount = anonymousParticipantCount
self.callCid = callCid
self.createdAt = createdAt
self.participantsCountByRole = participantsCountByRole
self.sessionId = sessionId
self.type = type
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case anonymousParticipantCount = "anonymous_participant_count"
case callCid = "call_cid"
case createdAt = "created_at"
case participantsCountByRole = "participants_count_by_role"
case sessionId = "session_id"
case type
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(anonymousParticipantCount, forKey: .anonymousParticipantCount)
try container.encode(callCid, forKey: .callCid)
try container.encode(createdAt, forKey: .createdAt)
try container.encode(participantsCountByRole, forKey: .participantsCountByRole)
try container.encode(sessionId, forKey: .sessionId)
try container.encode(type, forKey: .type)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,26 @@ import Foundation

public struct CallSessionResponse: Codable, JSONEncodable, Hashable {
public var acceptedBy: [String: Date]
public var anonymousParticipantCount: Int?
public var endedAt: Date?
public var id: String
public var liveEndedAt: Date?
public var liveStartedAt: Date?
public var missedBy: [String: Date]?
public var participants: [CallParticipantResponse]
public var participantsCountByRole: [String: Int]
public var rejectedBy: [String: Date]
public var startedAt: Date?
public var timerEndsAt: Date?

public init(acceptedBy: [String: Date], endedAt: Date? = nil, id: String, liveEndedAt: Date? = nil, liveStartedAt: Date? = nil, participants: [CallParticipantResponse], participantsCountByRole: [String: Int], rejectedBy: [String: Date], startedAt: Date? = nil, timerEndsAt: Date? = nil) {
public init(acceptedBy: [String: Date], anonymousParticipantCount: Int?, endedAt: Date? = nil, id: String, liveEndedAt: Date? = nil, liveStartedAt: Date? = nil, missedBy: [String: Date]?, participants: [CallParticipantResponse], participantsCountByRole: [String: Int], rejectedBy: [String: Date], startedAt: Date? = nil, timerEndsAt: Date? = nil) {
self.acceptedBy = acceptedBy
self.anonymousParticipantCount = anonymousParticipantCount
self.endedAt = endedAt
self.id = id
self.liveEndedAt = liveEndedAt
self.liveStartedAt = liveStartedAt
self.missedBy = missedBy
self.participants = participants
self.participantsCountByRole = participantsCountByRole
self.rejectedBy = rejectedBy
Expand All @@ -35,10 +39,12 @@ public struct CallSessionResponse: Codable, JSONEncodable, Hashable {

public enum CodingKeys: String, CodingKey, CaseIterable {
case acceptedBy = "accepted_by"
case anonymousParticipantCount = "anonymous_participant_count"
case endedAt = "ended_at"
case id
case liveEndedAt = "live_ended_at"
case liveStartedAt = "live_started_at"
case missedBy = "missed_by"
case participants
case participantsCountByRole = "participants_count_by_role"
case rejectedBy = "rejected_by"
Expand All @@ -51,14 +57,17 @@ public struct CallSessionResponse: Codable, JSONEncodable, Hashable {
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(acceptedBy, forKey: .acceptedBy)
try container.encodeIfPresent(anonymousParticipantCount, forKey: .anonymousParticipantCount)
try container.encodeIfPresent(endedAt, forKey: .endedAt)
try container.encode(id, forKey: .id)
try container.encodeIfPresent(liveEndedAt, forKey: .liveEndedAt)
try container.encodeIfPresent(liveStartedAt, forKey: .liveStartedAt)
try container.encodeIfPresent(missedBy, forKey: .missedBy)
try container.encode(participants, forKey: .participants)
try container.encode(participantsCountByRole, forKey: .participantsCountByRole)
try container.encode(rejectedBy, forKey: .rejectedBy)
try container.encodeIfPresent(startedAt, forKey: .startedAt)
try container.encodeIfPresent(timerEndsAt, forKey: .timerEndsAt)
}
}

21 changes: 20 additions & 1 deletion Sources/StreamVideo/OpenApi/generated/Models/WSEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable {
case typeCallRecordingStoppedEvent(CallRecordingStoppedEvent)
case typeCallRejectedEvent(CallRejectedEvent)
case typeCallRingEvent(CallRingEvent)
case typeCallRtmpBroadcastFailedEvent(CallRtmpBroadcastFailedEvent)
case typeCallRtmpBroadcastStartedEvent(CallRtmpBroadcastStartedEvent)
case typeCallRtmpBroadcastStoppedEvent(CallRtmpBroadcastStoppedEvent)
case typeCallSessionEndedEvent(CallSessionEndedEvent)
case typeCallSessionParticipantCountsUpdatedEvent(CallSessionParticipantCountsUpdatedEvent)
case typeCallSessionParticipantJoinedEvent(CallSessionParticipantJoinedEvent)
case typeCallSessionParticipantLeftEvent(CallSessionParticipantLeftEvent)
case typeCallSessionStartedEvent(CallSessionStartedEvent)
Expand Down Expand Up @@ -101,12 +103,16 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable {
return value.type
case .typeCallRingEvent(let value):
return value.type
case .typeCallRtmpBroadcastFailedEvent(let value):
return value.type
case .typeCallRtmpBroadcastStartedEvent(let value):
return value.type
case .typeCallRtmpBroadcastStoppedEvent(let value):
return value.type
case .typeCallSessionEndedEvent(let value):
return value.type
case .typeCallSessionParticipantCountsUpdatedEvent(let value):
return value.type
case .typeCallSessionParticipantJoinedEvent(let value):
return value.type
case .typeCallSessionParticipantLeftEvent(let value):
Expand Down Expand Up @@ -189,12 +195,16 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable {
return value
case .typeCallRingEvent(let value):
return value
case .typeCallRtmpBroadcastFailedEvent(let value):
return value
case .typeCallRtmpBroadcastStartedEvent(let value):
return value
case .typeCallRtmpBroadcastStoppedEvent(let value):
return value
case .typeCallSessionEndedEvent(let value):
return value
case .typeCallSessionParticipantCountsUpdatedEvent(let value):
return value
case .typeCallSessionParticipantJoinedEvent(let value):
return value
case .typeCallSessionParticipantLeftEvent(let value):
Expand Down Expand Up @@ -278,12 +288,16 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable {
try container.encode(value)
case .typeCallRingEvent(let value):
try container.encode(value)
case .typeCallRtmpBroadcastFailedEvent(let value):
try container.encode(value)
case .typeCallRtmpBroadcastStartedEvent(let value):
try container.encode(value)
case .typeCallRtmpBroadcastStoppedEvent(let value):
try container.encode(value)
case .typeCallSessionEndedEvent(let value):
try container.encode(value)
case .typeCallSessionParticipantCountsUpdatedEvent(let value):
try container.encode(value)
case .typeCallSessionParticipantJoinedEvent(let value):
try container.encode(value)
case .typeCallSessionParticipantLeftEvent(let value):
Expand Down Expand Up @@ -399,6 +413,9 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable {
} else if dto.type == "call.ring" {
let value = try container.decode(CallRingEvent.self)
self = .typeCallRingEvent(value)
} else if dto.type == "call.rtmp_broadcast_failed" {
let value = try container.decode(CallRtmpBroadcastFailedEvent.self)
self = .typeCallRtmpBroadcastFailedEvent(value)
} else if dto.type == "call.rtmp_broadcast_started" {
let value = try container.decode(CallRtmpBroadcastStartedEvent.self)
self = .typeCallRtmpBroadcastStartedEvent(value)
Expand All @@ -408,6 +425,9 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable {
} else if dto.type == "call.session_ended" {
let value = try container.decode(CallSessionEndedEvent.self)
self = .typeCallSessionEndedEvent(value)
} else if dto.type == "call.session_participant_count_updated" {
let value = try container.decode(CallSessionParticipantCountsUpdatedEvent.self)
self = .typeCallSessionParticipantCountsUpdatedEvent(value)
} else if dto.type == "call.session_participant_joined" {
let value = try container.decode(CallSessionParticipantJoinedEvent.self)
self = .typeCallSessionParticipantJoinedEvent(value)
Expand Down Expand Up @@ -456,4 +476,3 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable {
}

}

8 changes: 8 additions & 0 deletions StreamVideo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,8 @@
84D6494429E9AD08002CA428 /* CallIngressResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D6494229E9AD08002CA428 /* CallIngressResponse.swift */; };
84D6494729E9F2D0002CA428 /* WebRTCClient_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D6494629E9F2D0002CA428 /* WebRTCClient_Tests.swift */; };
84D6E53A2B3AD10000D0056C /* RepeatingTimer_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D6E5392B3AD10000D0056C /* RepeatingTimer_Tests.swift */; };
84D91E9C2C7CB0AA00B163A0 /* CallSessionParticipantCountsUpdatedEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D91E9A2C7CB0AA00B163A0 /* CallSessionParticipantCountsUpdatedEvent.swift */; };
84D91E9D2C7CB0AA00B163A0 /* CallRtmpBroadcastFailedEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D91E9B2C7CB0AA00B163A0 /* CallRtmpBroadcastFailedEvent.swift */; };
84DC382D29A8B9EC00946713 /* CallParticipantMenuAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DC382C29A8B9EC00946713 /* CallParticipantMenuAction.swift */; };
84DC382F29A8BB8D00946713 /* CallParticipantsInfoViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DC382E29A8BB8D00946713 /* CallParticipantsInfoViewModel.swift */; };
84DC388F29ADFCFD00946713 /* CodableHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DC383D29ADFCFB00946713 /* CodableHelper.swift */; };
Expand Down Expand Up @@ -1923,6 +1925,8 @@
84D6494229E9AD08002CA428 /* CallIngressResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CallIngressResponse.swift; sourceTree = "<group>"; };
84D6494629E9F2D0002CA428 /* WebRTCClient_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebRTCClient_Tests.swift; sourceTree = "<group>"; };
84D6E5392B3AD10000D0056C /* RepeatingTimer_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepeatingTimer_Tests.swift; sourceTree = "<group>"; };
84D91E9A2C7CB0AA00B163A0 /* CallSessionParticipantCountsUpdatedEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CallSessionParticipantCountsUpdatedEvent.swift; sourceTree = "<group>"; };
84D91E9B2C7CB0AA00B163A0 /* CallRtmpBroadcastFailedEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CallRtmpBroadcastFailedEvent.swift; sourceTree = "<group>"; };
84DC382C29A8B9EC00946713 /* CallParticipantMenuAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallParticipantMenuAction.swift; sourceTree = "<group>"; };
84DC382E29A8BB8D00946713 /* CallParticipantsInfoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallParticipantsInfoViewModel.swift; sourceTree = "<group>"; };
84DC383D29ADFCFB00946713 /* CodableHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CodableHelper.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4084,6 +4088,8 @@
84DC383E29ADFCFC00946713 /* Models */ = {
isa = PBXGroup;
children = (
84D91E9B2C7CB0AA00B163A0 /* CallRtmpBroadcastFailedEvent.swift */,
84D91E9A2C7CB0AA00B163A0 /* CallSessionParticipantCountsUpdatedEvent.swift */,
841AE1892C738CCC005B6560 /* LayoutSettings.swift */,
844982432C738A830029734D /* DeleteCallRequest.swift */,
844982402C738A830029734D /* DeleteCallResponse.swift */,
Expand Down Expand Up @@ -5315,6 +5321,7 @@
8409465629AF4EEC007AF5BF /* CallReactionEvent.swift in Sources */,
84DCA21F2A39DA15000C3411 /* APIHelper.swift in Sources */,
84DC38D329ADFCFD00946713 /* CallEndedEvent.swift in Sources */,
84D91E9D2C7CB0AA00B163A0 /* CallRtmpBroadcastFailedEvent.swift in Sources */,
84A737D028F4716E001A6769 /* models.pb.swift in Sources */,
846D16222A52B8D00036CE4C /* MicrophoneManager.swift in Sources */,
842E70DB2B91BE1700D2D68B /* ListTranscriptionsResponse.swift in Sources */,
Expand Down Expand Up @@ -5345,6 +5352,7 @@
8490DD1F298D39D9007E53D2 /* JsonEventDecoder.swift in Sources */,
40FB15192BF77EE700D5E580 /* StreamCallStateMachine+IdleStage.swift in Sources */,
84BAD7842A6C01AF00733156 /* BroadcastBufferReader.swift in Sources */,
84D91E9C2C7CB0AA00B163A0 /* CallSessionParticipantCountsUpdatedEvent.swift in Sources */,
846E4AF529CDEA66003733AB /* ConnectUserDetailsRequest.swift in Sources */,
846D16262A52CE8C0036CE4C /* SpeakerManager.swift in Sources */,
841BAA3A2BD15CDE000C73E4 /* Location.swift in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions StreamVideoTests/Mock/MockResponseBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ class MockResponseBuilder {
) -> CallSessionResponse {
CallSessionResponse(
acceptedBy: acceptedBy,
anonymousParticipantCount: 0,
endedAt: liveEndedAt,
id: cid,
liveEndedAt: liveEndedAt,
liveStartedAt: liveStartedAt,
missedBy: [:],
participants: [],
participantsCountByRole: [:],
rejectedBy: rejectedBy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ extension CallSessionResponse {
) -> CallSessionResponse {
.init(
acceptedBy: acceptedBy,
anonymousParticipantCount: 0,
endedAt: endedAt,
id: id,
liveEndedAt: liveEndedAt,
liveStartedAt: liveStartedAt,
missedBy: [:],
participants: participants,
participantsCountByRole: participantsCountByRole,
rejectedBy: rejectedBy,
Expand Down

0 comments on commit 0e8e550

Please sign in to comment.