-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added subscribe and unsubscribe for notification service
- Loading branch information
1 parent
317d238
commit 3e0eb89
Showing
7 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Foundation | ||
import VoxeetSDK | ||
|
||
enum Event: String { | ||
case invitationReceived = "SUBSCRIPTION_TYPE_INVITATION_RECEIVED" | ||
case activeParticipants = "SUBSCRIPTION_TYPE_ACTIVE_PARTICIPANTS" | ||
case conferenceCreated = "SUBSCRIPTION_TYPE_CONFERENCE_CREATED" | ||
case conferenceEnded = "SUBSCRIPTION_TYPE_CONFERENCE_ENDED" | ||
case participantJoined = "SUBSCRIPTION_TYPE_PARTICIPANT_JOINED" | ||
case participantLeft = "SUBSCRIPTION_TYPE_PARTICIPANT_LEFT" | ||
} | ||
|
||
internal struct SubscriptionDTO { | ||
|
||
static func create(with dictionary: [String: Any]) -> SubscriptionDTO? { | ||
guard | ||
let type: String = dictionary.value(for: Keys.type), | ||
let conferenceAlias: String = dictionary.value(for: Keys.conferenceAlias) | ||
else { return nil } | ||
|
||
return SubscriptionDTO(type: type, conferenceAlias: conferenceAlias) | ||
} | ||
|
||
let type: String | ||
let conferenceAlias: String | ||
|
||
func subscription() -> VTSubscribeBase? { | ||
switch type { | ||
case Event.invitationReceived.rawValue: | ||
return VTSubscribeInvitation(conferenceAlias: conferenceAlias) | ||
case Event.activeParticipants.rawValue: | ||
return VTSubscribeActiveParticipants(conferenceAlias: conferenceAlias) | ||
case Event.conferenceCreated.rawValue: | ||
return VTSubscribeConferenceCreated(conferenceAlias: conferenceAlias) | ||
case Event.conferenceEnded.rawValue: | ||
return VTSubscribeConferenceEnded(conferenceAlias: conferenceAlias) | ||
case Event.participantJoined.rawValue: | ||
return VTSubscribeParticipantJoined(conferenceAlias: conferenceAlias) | ||
case Event.participantLeft.rawValue: | ||
return VTSubscribeParticipantLeft(conferenceAlias: conferenceAlias) | ||
default: | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
// MARK: - ReactModelMappable | ||
extension SubscriptionDTO: ReactModelMappable { | ||
func toReactModel() -> ReactModelType { | ||
return [ | ||
Keys.type: type, | ||
Keys.conferenceAlias: conferenceAlias | ||
].mapKeysToRawValue() | ||
} | ||
} | ||
|
||
// MARK: - ReactModel Keys | ||
private enum Keys: String { | ||
case type, conferenceAlias | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** The SubscriptionType model gathers the subscription types. */ | ||
export enum SubscriptionType { | ||
InvitationReceived = 'SUBSCRIPTION_TYPE_INVITATION_RECEIVED', | ||
ActiveParticipants = 'SUBSCRIPTION_TYPE_ACTIVE_PARTICIPANTS', | ||
ConferenceCreated = 'SUBSCRIPTION_TYPE_CONFERENCE_CREATED', | ||
ConferenceEnded = 'SUBSCRIPTION_TYPE_CONFERENCE_ENDED', | ||
ParticipantJoined = 'SUBSCRIPTION_TYPE_PARTICIPANT_JOINED', | ||
ParticipantLeft = 'SUBSCRIPTION_TYPE_PARTICIPANT_LEFT', | ||
} | ||
|
||
/** The Subscription model is an interface for all subscription types. */ | ||
export interface Subscription { | ||
/** The subscription type. */ | ||
type: string; | ||
/** The conference alias. */ | ||
conferenceAlias: string; | ||
} |