//call received event handler public void AudioVideoCall_Received(CallReceivedEventArgs <AudioVideoCall> e) { if (_state == TranscriptRecorderState.Terminated) { NonBlockingConsole.WriteLine("Error: AVTranscriptRecorder is shutdown."); // TODO: Error message return; } if (_audioVideoCall != null) { NonBlockingConsole.WriteLine("Warn: AVCall already exists for this Conversation. Shutting down previous call..."); // TODO: Info message TerminateCall(); } _state = TranscriptRecorderState.Initialized; _waitForAudioVideoCallTerminated.Reset(); //Type checking was done by the platform; no risk of this being any // type other than the type expected. _audioVideoCall = e.Call; // Call: StateChanged: Only hooked up for logging, to show the call // state transitions. _audioVideoCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(AudioVideoCall_StateChanged); // Subscribe for the flow configuration requested event; the flow will be used to send the media. // Ultimately, as a part of the callback, the media will be sent/recieved. _audioVideoCall.AudioVideoFlowConfigurationRequested += new EventHandler <AudioVideoFlowConfigurationRequestedEventArgs>(AudioVideoCall_FlowConfigurationRequested); _audioVideoCall.ConversationChanged += new EventHandler <ConversationChangedEventArgs>(AudioVideoCall_ConversationChanged); // Remote Participant URI represents the far end (caller) in this // conversation. Toast is the message set by the caller as the 'greet' // message for this call. In Microsoft Lync, the toast will // show up in the lower-right of the screen. // TODO: change this to preserve confidentiality in the video demo //NonBlockingConsole.WriteLine("Call Received! From: " + e.RemoteParticipant.Uri + " Toast is: " + e.ToastMessage.Message); NonBlockingConsole.WriteLine("Call Received! From: " + e.RemoteParticipant.Uri); //NonBlockingConsole.WriteLine("Call Received!"); Message m = new Message("AudioVideoCall Received. Inbound call state: " + _audioVideoCall.State.ToString(), e.RemoteParticipant.DisplayName, e.RemoteParticipant.UserAtHost, e.RemoteParticipant.Uri, MessageType.Audio, _transcriptRecorder.Conversation.Id, MessageDirection.Incoming); _transcriptRecorder.OnMessageReceived(m); // Accept the call. Before transferring the call, it must be in the Established state. // Note that the docs are wrong in the state machine for the AVCall. BeginEstablish // should be called on outgoing calls, not incoming calls. _audioVideoCall.BeginAccept(AudioVideoCallAccepted, _audioVideoCall); // Wait for a few seconds to give time for the call to get to the Established state. //_waitForAudioVideoCallAccepted.WaitOne(2000); NonBlockingConsole.WriteLine("Inbound call state is {0}\n", _audioVideoCall.State.ToString()); }
public void InstantMessagingCall_Received(CallReceivedEventArgs <InstantMessagingCall> e) { if (_state == TranscriptRecorderState.Terminated) { NonBlockingConsole.WriteLine("Error: IMTranscriptRecorder is shutdown."); // TODO: Info message return; } if (_instantMessagingCall != null) { NonBlockingConsole.WriteLine("Warn: IMCall already exists for this Conversation. Shutting down previous call..."); // TODO: Info message TerminateCall(); } _state = TranscriptRecorderState.Initialized; _waitForIMCallTerminated.Reset(); // Type checking was done by the platform; no risk of this being any // type other than the type expected. _instantMessagingCall = e.Call; // Call: StateChanged: Only hooked up for logging, to show the call // state transitions. _instantMessagingCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(InstantMessagingCall_StateChanged); _instantMessagingCall.InstantMessagingFlowConfigurationRequested += new EventHandler <InstantMessagingFlowConfigurationRequestedEventArgs>(InstantMessagingCall_FlowConfigurationRequested); _instantMessagingCall.ConversationChanged += new EventHandler <ConversationChangedEventArgs>(InstantMessagingCall_ConversationChanged); // Remote Participant URI represents the far end (caller) in this // conversation. Toast is the message set by the caller as the // 'greet' message for this call. In Microsoft Lync, the // toast will show up in the lower-right of the screen. // TODO: Change to protect privacy // NonBlockingConsole.WriteLine("IMCall Received! From: " + e.RemoteParticipant.Uri + " Toast is: " + e.ToastMessage.Message); NonBlockingConsole.WriteLine("IMCall Received! From: " + e.RemoteParticipant.Uri); // Console.Writelin("IMCall Received!"); Message m = new Message("InstantMessagingCall Received. Inbound call state: " + _instantMessagingCall.State.ToString(), e.RemoteParticipant.DisplayName, e.RemoteParticipant.UserAtHost, e.RemoteParticipant.Uri, MessageType.InstantMessage, _transcriptRecorder.Conversation.Id, MessageDirection.Incoming); _transcriptRecorder.OnMessageReceived(m); // Now, accept the call. EndAcceptCall will be raised on the // same thread. _instantMessagingCall.BeginAccept(InstantMessagingCallAcceptedCallBack, _instantMessagingCall); }
void Conversation_StateChanged(object sender, StateChangedEventArgs <ConversationState> e) { Conversation conv = sender as Conversation; NonBlockingConsole.WriteLine("Conversation {0} state changed from " + e.PreviousState + " to " + e.State, conv.LocalParticipant.UserAtHost); Message m = new Message("Conversation state changed from " + e.PreviousState.ToString() + " to " + e.State.ToString(), MessageType.ConversationInfo, _conversation.Id); _transcriptRecorder.OnMessageReceived(m); if (e.State == ConversationState.Established || e.State == ConversationState.Conferenced) { _waitForConversationJoined.Set(); } else if (e.State == ConversationState.Terminating || e.State == ConversationState.Terminated) { _waitForConversationTerminated.Set(); this.Shutdown(); } }
public void ConferenceInviteAccepted(IAsyncResult result) { try { ConferenceInvitation invite = result.AsyncState as ConferenceInvitation; // ConferenceInvite already accepted in TranscriptRecorder.ConferenceInvitation_AcceptCompleted() Message m = new Message("ConferenceSession.ConferenceInviteAccepted()", MessageType.ConferenceInfo, _conversation.Id, invite.ConferenceUri); _transcriptRecorder.OnMessageReceived(m); ConferenceJoinOptions cjo = new ConferenceJoinOptions(); //cjo.JoinAsTrustedApplication = false; _conversation.ConferenceSession.BeginJoin(cjo, EndJoinInvitedConference, invite); } catch (RealTimeException ex) { NonBlockingConsole.WriteLine("invite.EndAccept failed. Exception: {0}", ex.ToString()); } catch (InvalidOperationException ex) { NonBlockingConsole.WriteLine("m_conversation.ConferenceSession.BeginJoin failed. Exception: {0}", ex.ToString()); } }