/// <summary> /// Called when a button is pressed in the dial pad dialog. /// /// Sends the DTMF tone using AudioChannel.BeginSendDtmf() /// </summary> void dialpad_DialPadPressed(string tone) { //sends a set of characters (in this case one) as a dial tone try { AsyncCallback callback = new AsyncOperationHandler(audioChannel.EndSendDtmf).Callback; audioChannel.BeginSendDtmf(tone, callback, null); } catch (LyncClientException lyncClientException) { Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (LyncModelExceptionHelper.IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. Console.WriteLine("Error: " + systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } }
//***************************************************************************************** // VideoChannel related actions // // The video channel action will behave differently depending on whether the audio is already // connected. // // If audio is not connected, starting video is equivalent to connecting the modality. If the // conversation already has audio, starting video will start the outgoing video stream. The // other participants in the conversation also need to start their own video. // // Stopping the video channel will stop both outgoing and incoming video. It will remove video // from the conversation. // //***************************************************************************************** /// <summary> /// Starts the video channel: VideoChannel.BeginStart() /// </summary> private void buttonStartVideo_Click(object sender, EventArgs e) { //starts a video call or the video stream in a audio call AsyncCallback callback = new AsyncOperationHandler(videoChannel.EndStart).Callback; try { videoChannel.BeginStart(callback, null); } catch (LyncClientException lyncClientException) { Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (LyncModelExceptionHelper.IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. Console.WriteLine("Error: " + systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } }
/// <summary> /// Retrieves the modality (audio + video): AvModality.BeginRetrieve() /// </summary> private void buttonRetrieve_Click(object sender, EventArgs e) { //retrieves a call from hold (applies for both audio and video) //the video state will be remembered from before the call was held AsyncCallback callback = new AsyncOperationHandler(avModality.EndRetrieve).Callback; try { avModality.BeginRetrieve(callback, null); } catch (LyncClientException lyncClientException) { Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (LyncModelExceptionHelper.IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. Console.WriteLine("Error: " + systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } }
/// <summary> /// Forwards the call to a contact or phone number. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonForward_Click(object sender, EventArgs e) { //since forwarding needs a contact, will show a dialog to get user input SelectContactDialog contactDialog = new SelectContactDialog(client.ContactManager); contactDialog.ShowDialog(); //if a contact is selected if (contactDialog.DialogResult == DialogResult.OK && contactDialog.Contact != null) { //transfers the call (both audio and video) to the specified contact AsyncCallback callback = new AsyncOperationHandler(avModality.EndForward).Callback; try { avModality.BeginForward(contactDialog.Contact, callback, null); } catch (LyncClientException lyncClientException) { Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (LyncModelExceptionHelper.IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. Console.WriteLine("Error: " + systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } } }
/// <summary> /// Holds the modality (audio + video): AvModality.BeginHold() /// </summary> private void buttonHold_Click(object sender, EventArgs e) { //puts the call on hold (applies for both audio and video) AsyncCallback callback = new AsyncOperationHandler(avModality.EndHold).Callback; try { avModality.BeginHold(callback, null); } catch (LyncClientException lyncClientException) { Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (LyncModelExceptionHelper.IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. Console.WriteLine("Error: " + systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } }
/// <summary> /// Disconnects the modality: AvModality.BeginDisconnect() /// </summary> private void buttonDisconnectAudio_Click(object sender, EventArgs e) { //ends an audio call or conference by connecting the AvModality try { AsyncCallback callback = new AsyncOperationHandler(avModality.EndDisconnect).Callback; avModality.BeginDisconnect(ModalityDisconnectReason.None, callback, null); } catch (LyncClientException lyncClientException) { Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (LyncModelExceptionHelper.IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. Console.WriteLine("Error: " + systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } }
/// <summary> /// Starts the video channel: VideoChannel.BeginStop() /// </summary> private void StopVideo() { //removes video from the conversation AsyncCallback callback = new AsyncOperationHandler(_videoChannel.EndStop).Callback; try { _videoChannel.BeginStop(callback, null); } catch (LyncClientException lyncClientException) { Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (LyncModelExceptionHelper.IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. Console.WriteLine("Error: " + systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } }
//***************************************************************************************** // VideoChannel related actions // // The video channel action will behave differently depending on whether the audio is already // connected. // // If audio is not connected, starting video is equivalent to connecting the modality. If the // conversation already has audio, starting video will start the outgoing video stream. The // other participants in the conversation also need to start their own video. // // Stopping the video channel will stop both outgoing and incoming video. It will remove video // from the conversation. // //***************************************************************************************** /// <summary> /// Starts the video channel: VideoChannel.BeginStart() /// </summary> private void StartVideo() { _log.Debug("StartVideo"); if (!_videoChannel.CanInvoke(ChannelAction.Start)) { _log.Debug("StartVideo can't start"); return; } //starts a video call or the video stream in a audio call AsyncCallback callback = new AsyncOperationHandler(_videoChannel.EndStart).Callback; try { _videoChannel.BeginStart(callback, null); } catch (LyncClientException lyncClientException) { Console.WriteLine(lyncClientException); } catch (SystemException systemException) { if (LyncModelExceptionHelper.IsLyncException(systemException)) { // Log the exception thrown by the Lync Model API. _log.ErrorException("Error: ", systemException); } else { // Rethrow the SystemException which did not come from the Lync Model API. throw; } } }
/// <summary> /// Connects the modality (audio): AvModality.BeginConnect() /// </summary> private void Connect() { //starts an audio call or conference by connecting the AvModality try { _log.Debug("ConnectAudio BeginConnect"); AsyncCallback callback = new AsyncOperationHandler(_avModality.EndConnect).Callback; _avModality.BeginConnect(callback, null); } catch (LyncClientException lyncClientException) { _log.ErrorException("", lyncClientException); } catch (Exception systemException) { _log.ErrorException("", systemException); } }