返回新的来电uri

时间:2015-09-30 05:55:44

标签: c# vb.net lync-2013

我使用这个简单的代码来接听来电和来电者的Uri。如果用户打开了多个Lync会话,则由于静态索引,它始终会返回第一个会话。我如何能够获得新的连接索引,以便获得适当的调用者权限?

    Imports Microsoft.Lync.Model
Imports Microsoft.Lync.Model.Conversation
Imports Lync = Microsoft.Lync.Model.Conversation


Public Class myLync
    Private _LyncClient As LyncClient
    Public WithEvents _ConversationMgr As Microsoft.Lync.Model.Conversation.ConversationManager
    Public WithEvents _conv As Conversation

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            _LyncClient = LyncClient.GetClient()
            _ConversationMgr = _LyncClient.ConversationManager
        Catch ex As Exception
        End Try
 End Sub

 Private Sub _ConversationMgr_ConversationAdded(ByVal sender As Object, ByVal e As Microsoft.Lync.Model.Conversation.ConversationManagerEventArgs) Handles _ConversationMgr.ConversationAdded
        AddHandler e.Conversation.Modalities(ModalityTypes.AudioVideo).ModalityStateChanged, AddressOf AVModalityStateChanged
 End Sub

 Private Sub AVModalityStateChanged(ByVal sender As Object, ByVal e As ModalityStateChangedEventArgs)
        Select Case e.NewState
            Case ModalityState.Notified
                Dim Uri = _ConversationMgr.Conversations.Item(0).Participants.Item(1).Contact.Uri
        End Select
 End Sub

1 个答案:

答案 0 :(得分:1)

AVModalityStateChanged(ByVal sender As Object, ByVal e As ModalityStateChangedEventArgs)中,sender参数可以从那里转换为AVModality,您可以访问该参与者。

请原谅我的#,但它看起来像是: -

  private void Participant_ModalityStateChanged(object sender, ModalityStateChangedEventArgs e)
    {
        if (e.NewState == ModalityState.Connected)
        {
            var modality = (AVModality) sender;
            var participant = modality.Participant;
            var uri = participant.Contact.Uri;
        }
    }