import { DeviceEventEmitter, EmitterSubscription, NativeEventEmitter, NativeModules, Platform, } from 'react-native'; const iosEventEmitter: any = Platform.OS === 'ios' && new NativeEventEmitter(NativeModules.IEventEmmiter); /** * @name Events * @description * This module handle every events that come from native Rainbow.
* To receive them, you need to subscribe individually to each of the following events see method provided by the class below.
* @fires Events#ContactsUpdated * @fires Events#LocalContactsUpdated * @fires Events#AuthenticationResult * @fires Events#CurrentUserSignedOut * @fires Events#PresenceUpdated * @fires Events#ConnectedUserUpdated * @fires Events#ResetPswResult * @fires Events#CurrentCall * @fires Events#CallAdded * @fires Events#CallUpdated * @fires Events#CallRemoved * @fires Events#MicStateUpdated * @fires Events#SpeakerStateUpdated * @fires Events#SessionAdded * @fires Events#SessionUpdated * @fires Events#SecondSessionAdded * @fires Events#SecondSessionUpdated * @fires Events#SessionRemoved * @fires Events#SessionAllRemoved * @fires Events#NomadicUpdated * @fires Events#CallForwardingResult * @fires Events#CallForwardStatus * @fires Events#CallForwardOptionsUpdated * @fires Events#TelephonyStatusUpdated * @fires Events#TelephonyCapabilityUpdate * @fires Events#CallForwardNumberDestination * @fires Events#SessionsCountUpdated * @fires Events#SecondSessionRemoved * @fires Events#MakePbxCallResponse * @fires Events#RetrieveForbidden * @fires Events#NomadicNumberUpdated * @fires Events#NoNomadicNumberEntered * @fires Events#ConversationsUpdated * @fires Events#CallLogsUpdated * @fires Events#MissedCallLogsUpdated * @fires Events#MissedCallUnreadCounterUpdated * @fires Events#VoiceMailUnreadCounterUpdated * @fires Events#VoiceMailCapabilityUpdate * @fires Events#MessagesUpdated * @fires Events#IsTyping * @fires Events#FileDownloadProgressUpdated * @fires Events#FileDownloadFinished * @fires Events#ThumpnailUpdated * @fires Events#FileAttachProgressUpdated * @fires Events#FileAttachFinished * @fires Events#AppConfiguration * @fires Events#AppVersion * @fires Events#ContactsSearchResult * @fires Events#SearchError * @fires Events#SearchFinished * @fires Events#BubblesListUpdated * @fires Events#OnBubbleUpdated * @fires Events#CreateBubbleResult * @fires Events#AddParticipantResult * @fires Events#SentInvitationsUpdated * @fires Events#ReceivedInvitationsUpdated * @fires Events#InvitationResponse */ export enum EventType { /** * @event Events#ContactsUpdated * @public * @descriptionS Fired when the Rainbow roster contacts updated. */ ContactsUpdated = 'contactsUpdated', /** * @event Events#LocalContactsUpdated * @public * @descriptionS Fired when the local phone contacts updated. */ LocalContactsUpdated = 'localContactsUpdated', /** * @event Events#AuthenticationResult * @public * @descriptionS Fired when the Connected user logged in successfully. */ AuthenticationResult = 'authenticationResult', /** * @event Events#CurrentUserSignedOut * @public * @descriptionS Fired when the connected Rainbow user logged out. */ CurrentUserSignedOut = 'userSignedOut', /** * @event Events#PresenceUpdated * @public * @descriptionS Fired when the presence updated. */ PresenceUpdated = 'presenceUpdated', ContactsDetailUpdated = 'contactsDetailUpdated', /** * @event Events#ConnectedUserUpdated * @public * @descriptionS Fired when the Rainbow connected user information has updated. */ ConnectedUserUpdated = 'connectedUserUpdated', /** * @event Events#connectedUserPresenceUpdated * @public * @descriptionS Fired when the connected user presence has changed. */ ConnectedUserPresenceUpdated = 'connectedUserPresenceUpdated', /** * @event Events#ForgetPwdEmailResult * @public * @descriptionS Fired when you send a reset password email. */ ForgetPwdEmailResult = 'forgetPwdEmailResult', /** * @event Events#ResetPswResult * @public * @descriptionS Fired when you received a rest password result . */ ResetPswResult = 'resetPswResult', /** * @event Events#CurrentCall * @public * @descriptionS Fired when there is a current pbx or webrtc call. */ GetCurrentCall = 'current_call', /** * @event Events#CallAdded * @public * @descriptionS Fired when a webrtc call has been added. */ /** * @event CurrentConferenceCall * @Public * @description Fired when there is a current conference call. */ CurrentConferenceCall = 'currentConferenceCall', /** * @event ConferenceCapability * @Public * @description to check if the conference webrtc call is allowed or not. */ ConferenceCapability = 'conferenceCapability', /** * @event CurrentConferenceUpdated * @public * @description Fired when the conference call has been updated. */ CurrentConferenceUpdated = 'currentConferenceUpdated', /** * @event CurrentConferenceRemoved * @public * @description Fired when the current conference call has been ended. */ CurrentConferenceRemoved = 'currentConferenceRemoved', /** * @event Events#ConferenceCallAdded * @public * @descriptionS Fired when a new conference webrtc call has beeb added. */ ConferenceCallAdded = 'conferenceCallAdded', /** * @event Events#CallUpdated * @public * @descriptionS Fired when the active webrtc call has modified. */ P2PCallUpdated = 'p2pCallUpdated', /** * @event Events#MicStateUpdated * @public * @descriptionS Fired when the microphone state has muted/unmuted. */ MicStateUpdated = 'mic_state_updated', /** * @event Events#SpeakerStateUpdated * @public * @descriptionS Fired when the speaker state has been updated */ SpeakerStateUpdated = 'speaker_state_updated', /** * @event Events#SessionAdded * @public * @descriptionS Fired when a pbx call has been added. */ SessionAdded = 'sessionAdded', /** * @event Events#SessionUpdated * @public * @descriptionS Fired when the current pbx call has been updated. */ SessionUpdated = 'sessionUpdated', /** * @event Events#SecondSessionAdded * @public * @descriptionS Fired when a second pbx call has been added. */ SecondSessionAdded = 'secondSessionAdded', /** * @event Events#SecondSessionUpdated * @public * @descriptionS Fired when a second pbx call has been updated. */ SecondSessionUpdated = 'secondSessionUpdated', /** * @event Events#SessionRemoved * @public * @descriptionS Fired when the current active pbx call ended. */ SessionRemoved = 'sessionRemoved', /** * @event Events#SessionAllRemoved * @public * @descriptionS Fired when all the active pbx call has been ended. */ SessionAllRemoved = 'allSessionsRemoved', /** * @event Events#CallForwardingResult * @public * @descriptionS Fired when there is a change in the call forwarding status. */ CallForwardingResult = 'callForwardingResult', /** * @event Events#CallForwardStatus * @public * @descriptionS Fired withe the current forward status new value. */ CallForwardStatus = 'callForwardStatus', /** * @event Events#CallForwardOptionsUpdated * @public * @descriptionS Fired when the call forwarding options has been updated. */ CallForwardOptionsUpdated = 'callForwardOptionsUpdated', /** * @event Events#TelephonyStatusUpdated * @public * @descriptionS Fired when the telephony status has been updated. */ TelephonyStatusUpdated = 'telephonyStatusUpdated', /** * @event Events#TelephonyCapabilityUpdate * @public * @descriptionS Fired when the telephony capability has been updated. */ TelephonyCapabilityUpdate = 'telephonyCapabilityUpdate', /** * @event Events#LocalContactsUpdated * @public * @descriptionS Fired when the phone number to forward the call has been changed. */ CallForwardNumberDestination = 'callForwardNumberDestination', /** * @event Events#CallForwardNumberDestination * @public * @descriptionS Fired when the counts of the active sessions has been updated. */ SessionsCountUpdated = 'sessionsCountUpdated', /** * @event Events#SecondSessionRemoved * @public * @descriptionS Fired when the second session has been removed. */ SecondSessionRemoved = 'secondSessionRemoved', /** * @event Events#MakePbxCallResponse * @public * @descriptionS Fired when you failed to start a pbx call. */ MakePbxCallResponse = 'makePbxCallResponse', /** * @event Events#RetrieveForbidden * @public * @descriptionS Fired when retrieving the muted call has been failed . */ RetrieveForbidden = 'retrieveForbidden', /** * @event Events#NomadicNumberUpdated * @public * @descriptionS Fired when the nomadic number has been updated. */ NomadicNumberUpdated = 'nomadicNumberUpdated', NoNomadicNumberEntered = 'noNomadicNumberEntered', /** * @event Events#ConversationsUpdated * @public * @descriptionS Fired when conversations for the connected user has been updated. */ ConversationsUpdated = 'conversationsUpdated', /** * @event Events#CallLogsUpdated * @public * @descriptionS Fired when the callLogs for the connected user has been updated. */ CallLogsUpdated = 'callLogsUpdated', /** * @event Events#MissedCallLogsUpdated * @public * @descriptionS Fired when the missed callLogs for the connected user has been updated. */ MissedCallLogsUpdated = 'missedCallLogsUpdated', /** * @event Events#MissedCallUnreadCounterUpdated * @public * @descriptionS Fired when the counter of the unread missed calls has been Updated. */ MissedCallUnreadCounterUpdated = 'missedCallUnreadCounterUpdated', /** * @event Events#VoiceMailUnreadCounterUpdated * @public * @descriptionS Fired when the counter of the unread voice mail has been Updated. */ VoiceMailUnreadCounterUpdated = 'voiceMailUnreadCounterUpdated', /** * @event Events#VoiceMailCapabilityUpdate * @public * @descriptionS Fired when the voiceMail capability has been updated. */ VoiceMailCapabilityUpdate = 'voiceMailCapabilityUpdate', /** * @event Events#MessagesUpdated * @public * @descriptionS Fired when the IM has been updated. */ MessagesUpdated = 'messagesUpdated', /** * @event Events#IsTyping * @public * @descriptionS Fired when the typing state for IM changes. */ IsTyping = 'isTyping', /** * @event Events#FileDownloadProgressUpdated * @public * @descriptionS Fired when downloading file is on InProgress. */ FileDownloadProgressUpdated = 'fileDownloadProgressUpdated', /** * @event Events#FileDownloadFinished * @public * @descriptionS Fired when downloading the file has been finished. */ FileDownloadFinished = 'fileDownloadFinished', ThumpnailUpdated = 'thumpnailUpdated', /** * @event Events#FileAttachProgressUpdated * @public * @descriptionS Fired when attaching files. */ FileAttachProgressUpdated = 'fileAttachProgressUpdated', /** * @event Events#FileAttachFinished * @public * @descriptionS Fired when attaching files finished. */ FileAttachFinished = 'fileAttachFinished', // app config AppConfiguration = 'appConfig', AppVersion = 'appVersion', /** * @event Events#ContactsSearchResult * @public * @descriptionS Fired when there is an update in the contacts search result. */ ContactsSearchResult = 'contactsSearchResult', /** * @event Events#SearchError * @public * @descriptionS Fired when there is an error while doing a search . */ SearchError = 'searchError', /** * @event Events#SearchFinished * @public * @descriptionS Fired when the search for contacts finished. */ SearchFinished = 'searchFinished', /** * @event Events#BubblesListUpdated * @public * @descriptionS Fired when bubbles List has been updated. */ BubblesListUpdated = 'bubblesListUpdated', /** * @event Events#OnBubbleUpdated * @public * @descriptionS Fired when there is a bubble has been updated. */ OnBubbleUpdated = 'onBubbleUpdated', /** * @event Events#GetInvitedBubbles * @public * @descriptionS Get the invited bubbles. */ GetInvitedBubbles = 'getInvitedBubbles', /** * @event Events#InvitedBubblesResult * @public * @descriptionS Get the bubble invitation result. */ InvitedBubblesResult = 'invitedBubblesResult', /** * @event Events#CreateBubbleResult * @public * @descriptionS Fired after creation a bubble. */ CreateBubbleResult = 'createBubbleResult', /** * @event Events#AddParticipantResult * @public * @descriptionS Fired after adding a participant to a bubble. */ AddParticipantResult = 'addParticipantResult', /** * @event Events#SentInvitationsUpdated * @public * @descriptionS Fired when the sent invitations by the connected Rainbow user has been updated. */ SentInvitationsUpdated = 'sentInvitationsUpdated', /** * @event Events#ReceivedInvitationsUpdated * @public * @descriptionS Fired when the received invitations has been updated. */ ReceivedInvitationsUpdated = 'receivedInvitationsUpdated', InvitationResponse = 'invitationResponse', /** * @event Events#DeleteBubbleResult * @public * @description Fired when the user receive a delete bubble action result */ DeleteBubbleResult = 'deleteBubbleResult', /** * @event Events#LeaveBubbleResult * @public * @description Fired when the user receive a leave bubble action result */ LeaveBubbleResult = 'leaveBubbleResult', /** * @event Events#ArchiveBubbleResult * @public * @description Fired when the user receive an archive bubble action result */ ArchiveBubbleResult = 'archiveBubbleResult', /** * @event Events#UpdateBubbleResult * @public * @description Fired when the user receive an update bubble info action result */ UpdateBubbleResult = 'updateBubbleResult', /** * @event Events#NewBubbleImage * @public * @description Fired when the user upload a new profile image for a bubble. */ NewBubbleImage = 'newBubbleImage', /** * @event Events#UpdateBubbleImageResult * @public * @description Fired when the user modify the bubble profile image. */ UpdateBubbleImageResult = 'updateBubbleImageResult', /** * @event Events#GetBubbleOrganizer * @public * @description Fired when the user receive the bubble organizers action result */ GetBubbleOrganizer = 'getBubbleOrganizer', /** * @event Events#GetBubbleMembers * @public * @description Fired when the user receive the bubble members action result */ GetBubbleMembers = 'getBubbleMembers', /** * @event Events#GetBubbleParticipants * @public * @description Fired when the user receive the bubble participants action result */ GetBubbleParticipants = 'getBubbleParticipants', /** * @event Events#BubblePendingInvitationsCounter * @public * @description Fired when the user receive the bubble members action result */ BubblePendingInvitationsCounter = 'bubblePendingInvitationsCounter', /** * @event Events#AddContactToRoster * @public * @description Fired when the user invite rainbow user to his network */ AddContactToRoster = 'addContactToRoster', /** * @event Events#TotalNbOfPendingInvitations * @public * @description get the contact pending invitation count */ TotalNbOfPendingInvitations = 'totalNbOfPendingInvitations', /** * @event Events#ConferenceAttendeesUpdates * @public * @description Fired when one of the participants had been joined or leave to the conference. */ ConferenceAttendeesUpdates = 'conferenceAttendeesUpdates', /** * @event Events#HasConferenceParticipantJoinedVideoCall * @public * @description Fired when one of the participants start publishing a video in the conference room. */ HasConferenceParticipantJoinedVideoCall = 'HasConferenceParticipantJoinedVideoCall', /** * @event Events#ConferenceParticipantStatusUpdate * @public * @description Fired when one of the participants changes his status, for example: become muted, on hold ...etc. */ ConferenceParticipantStatusUpdate = 'ConferenceParticipantStatusUpdate', /** * @event Events#RemoveContact * @public * @description Fired when the user removes a Rainbow user from his network */ RemoveContact = 'removeContact', /** * @event Events#AreAllConfUserMuted * @public * @description check if all the conference users are muted or not */ AreAllConfUserMuted = 'areAllConfUserMuted', /** * @event Events#BubbleHasActiveConference * @public * @description check if all the bubble has an active conference. */ BubbleHasActiveConference = 'bubbleHasActiveConference', /** * @event Events#GetBubbleCustomData * @public * @description get the custom data of a bubble. */ GetBubbleCustomData = 'getBubbleCustomData', /** * @event Events#RemoveContactFromBubbleResult * @public * @description fired when a contact is removed from a bubble */ RemoveContactFromBubbleResult = 'removeContactFromBubbleResult', /** * @event Events#RemoveContactFromBubbleResult * @public * @description fired when a user promoted to be a bubble owner. */ PromoteBubbleOwnerResult = 'promoteBubbleOwnerResult', /** * @event Events#HangUpParticipantFailed * @public * @description fired when failed to hangup participant from conference. */ HangUpParticipantFailed = 'hangUpParticipantFailed', /** * @event Events#GetConnectedUserCustomData * @public * @description Get the custom data of the connected user. */ GetConnectedUserCustomData = 'getConnectedUserCustomData', /** * @event Events#GetBubbleByIdResult * @public * @description Get the bubble object from the bubble Jid */ GetBubbleByIdResult = 'getBubbleByIdResult', /** * @event Events#GetScreenSharingUpdate * @public * @description Get the screen sharing update */ GetConferenceScreenSharingUpdate = 'getConferenceScreenSharingUpdate', /** * @event Events#GetConferenceLockState * @public * @description Get the lock state of the conference */ GetConferenceLockState = 'getConferenceLockState', /** * @event Events#GetConferenceLockState * @public * @description Get the lock state of the conference */ GetActiveConferenceForBubbleResult = 'getActiveConferenceForBubbleResult', /** * @event Events#GetSharedFileSentWithBubbleResult * @public * @description Get the sent Shared File With Bubble Result */ GetSharedFileSentWithBubbleResult = 'getSharedFileSentWithBubbleResult', /** * @event Events#GetSharedFileReceivedWithBubbleResult * @public * @description Get the received Shared File With Bubble Result */ GetSharedFileReceivedWithBubbleResult = 'getSharedFileReceivedWithBubbleResult', /** * @event Events#GetSharedFileSentWithConversationResult * @public * @description Get the sent Shared File With Conversation Result */ GetSharedFileSentWithConversationResult = 'getSharedFileSentWithConversationResult', /** * @event Events#GetSharedFileReceivedWithConversationResult * @public * @description Get the received Shared File With Conversation Result */ GetSharedFileReceivedWithConversationResult = 'getSharedFileReceivedWithConversationResult', /** * @event Events#GetAllSharedFileWithPeerResult * @public * @description Get the all Shared File With peer (Conversation or Bubble) Result */ GetAllSharedFileWithPeerResult = 'getAllSharedFileWithPeerResult', /** * @event Events#IsNetworkAvailable * @public * @description to check if there available network. */ IsNetworkAvailable = "isNetworkAvailable", DisplayJoinBanner ="displayJoinBanner", GetHostNameResult = "getHostName", AuthStateChange = "authStateChange", GetConversationByJid = "getConversationByJid", OnRegistrationComplete = "onRegistrationComplete", RegisterByEmailResult= "onSendCodeComplete", ValidationTokenResult = "onValidationToken" } export interface IEventEmitter { addListener(e: EventType, listener: (eventData: any) => void): EmitterSubscription; } class EventEmitter implements IEventEmitter { /** * * @public * @method addListener * @param {EventType} e Name of the event to listen to. * @param {function} listener Function to invoke when the specified event is emitted. * @description * Adds a listener to be invoked when events of the specified type are * emitted.The data arguments emitted will be passed to the listener function. */ public addListener(e: EventType, listener: (eventData: any) => void) { if (Platform.OS === 'ios') { return iosEventEmitter.addListener(e, listener); } else { // Android return DeviceEventEmitter.addListener(e, listener); } } } export const eventEmitter: IEventEmitter = new EventEmitter();