public void OnCallEvent(CallSdkEvent sdkEvent) { var call = CallManager.Instance.GetCall(sdkEvent.CallId); if (call != null) { call.OnEvent(sdkEvent); } else { Debug.LogError($"Unknown Call with CallId = {sdkEvent.CallId}"); } }
public void OnEvent(CallSdkEvent callEvent) { Debug.Log($"Event {callEvent.Event} received by Call {CallId}"); if (callEvent.Event.Equals("Connected")) { Connected?.Invoke(this, callEvent.GetEventArgs <CallConnectedEventArgs>()); } else if (callEvent.Event.Equals("Disconnected")) { Disconnected?.Invoke(this, callEvent.GetEventArgs <CallDisconnectedEventArgs>()); } else if (callEvent.Event.Equals("Ringing")) { Ringing?.Invoke(this, callEvent.GetEventArgs <CallRingingEventArgs>()); } else if (callEvent.Event.Equals("Failed")) { Failed?.Invoke(this, callEvent.GetEventArgs <CallFailedEventArgs>()); } else if (callEvent.Event.Equals("AudioStarted")) { AudioStarted?.Invoke(this); } else if (callEvent.Event.Equals("SIPInfoReceived")) { SIPInfoReceived?.Invoke(this, callEvent.GetEventArgs <CallSIPInfoReceivedEventArgs>()); } else if (callEvent.Event.Equals("MessageReceived")) { MessageReceived?.Invoke(this, callEvent.GetEventArgs <CallMessageReceivedEventArgs>()); } else if (callEvent.Event.Equals("LocalVideoStreamAdded")) { var eventArgs = callEvent.GetEventArgs <CallLocalVideoStreamAddedEventArgs>(); var videoStream = CreateVideoStream(eventArgs.streamId); _localVideoStreams[eventArgs.streamId] = videoStream; eventArgs.VideoStream = videoStream; LocalVideoStreamAdded?.Invoke(this, eventArgs); } else if (callEvent.Event.Equals("LocalVideoStreamRemoved")) { var eventArgs = callEvent.GetEventArgs <CallLocalVideoStreamRemovedEventArgs>(); if (!_localVideoStreams.ContainsKey(eventArgs.streamId)) { return; } var videoStream = _localVideoStreams[eventArgs.streamId]; _localVideoStreams.Remove(eventArgs.streamId); eventArgs.VideoStream = videoStream; videoStream.Dispose(); LocalVideoStreamRemoved?.Invoke(this, eventArgs); } else if (callEvent.Event.Equals("ICETimeout")) { ICETimeout?.Invoke(this); } else if (callEvent.Event.Equals("ICECompleted")) { ICECompleted?.Invoke(this); } else if (callEvent.Event.Equals("EndpointAdded")) { var eventArgs = callEvent.GetEventArgs <CallEndpointAddedEventArgs>(); if (_endpoints.ContainsKey(eventArgs.endpointId)) { return; } eventArgs.Endpoint = AddEndpoint(eventArgs.endpointId); EndpointAdded?.Invoke(this, eventArgs); } else if (callEvent.Event.Equals("ActionCompleted")) { var eventArgs = callEvent.GetEventArgs <CallActionEventArgs>(); var completion = CallActions[eventArgs.RequestGuid]; completion?.Invoke(null); CallActions.Remove(eventArgs.RequestGuid); } else if (callEvent.Event.Equals("ActionFailed")) { var eventArgs = callEvent.GetEventArgs <CallActionFailedEventArgs>(); var completion = CallActions[eventArgs.RequestGuid]; completion?.Invoke(new Error(eventArgs.Code, eventArgs.Error)); CallActions.Remove(eventArgs.RequestGuid); } else { Debug.LogError($"Unexpected Event {callEvent.Event} for Call {CallId}"); } }