/// <summary> /// Called when a participant is removed from the conversation. /// /// Removes the participant from the roster listbox. /// </summary> void conversation_ParticipantRemoved(object sender, ParticipantCollectionChangedEventArgs e) { //error case, the participant wasn't actually removed if (e.StatusCode < 0) { Console.Out.WriteLine("Participant was not removed: code=" + e.StatusCode); return; } //posts the execution into the UI thread this.BeginInvoke(new MethodInvoker(delegate() { //finds the position of the participant to be removed in the roster listbox int removePosition = -1; for (int i = 0; i < listBoxRosterContacts.Items.Count; i++) { ParticipantItem item = listBoxRosterContacts.Items[i] as ParticipantItem; if (item != null && item.Participant.Equals(e.Participant)) { removePosition = i; break; } } //removes the participant from the roster listbox if (removePosition > 0) { listBoxRosterContacts.Items.RemoveAt(removePosition); } })); }
/// <summary> /// Handles the participant added event. Registers for events on the application sharing modality for the /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void _conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { //Is this added participant the local user? if (e.Participant.IsSelf) { //Store the application sharing modality of the local user so that //the user can request or release control of a remotely owned and shared resource. _LocalParticipantSharingModality = (ApplicationSharingModality)e.Participant.Modalities[ModalityTypes.ApplicationSharing]; //Enable or disable the Start Resource Sharing button according to the role of the local participant. //Roles can be Presenter or Attendee. if (e.Participant.Properties[ParticipantProperty.IsPresenter] != null) { this.Invoke(new EnableDisableButtonDelegate(EnableDisableButton), new object[] { StartSharingResource_Button, (Boolean)e.Participant.Properties[ParticipantProperty.IsPresenter] }); } //Register for the particpant property changed event to be notified when the role of the local user changes. e.Participant.PropertyChanged += Participant_PropertyChanged; this.Invoke(new ChangeLabelTextDelegate(ChangeLabelText), new object[] { SharingParticipationStateString_Label, "not sharing" }); } //Get the application sharing modality of the added participant and store it in a class dictionary field for easy access later. ApplicationSharingModality participantSharingModality = (ApplicationSharingModality)e.Participant.Modalities[ModalityTypes.ApplicationSharing]; _participantSharingModalities.Add(e.Participant.Contact.Uri, participantSharingModality); //register for important events on the application sharing modality of the new participant. participantSharingModality.ActionAvailabilityChanged += _sharingModality_ActionAvailabilityChanged; participantSharingModality.ModalityStateChanged += _sharingModality_ModalityStateChanged; }
void _onParticipantRemoved(object sender, ParticipantCollectionChangedEventArgs ea) { System.Console.WriteLine("part removed"); (ea.Participant.Modalities[ModalityTypes.InstantMessage] as InstantMessageModality).InstantMessageReceived -= (s, e) => _onMessageReceived(s, e, ea.Participant); }
private void ParticipantAdd(object sender, ParticipantCollectionChangedEventArgs e) { //e.Participant Participant p = e.Participant; foreach (DataRow dr in dtPar.Rows) { if (dr["Displayname"].ToString() == p.Properties[ParticipantProperty.Name].ToString()) { dr["JoinTime"] = GetNow(); dtPar.AcceptChanges(); bindingSource1.DataSource = dtPar; datagv1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; return; } } if ((Boolean)p.Properties[ParticipantProperty.IsAuthenticated]) { dtPar.Rows.Add(p.Properties[ParticipantProperty.Name].ToString(), "No", GetNow(), ""); } else { dtPar.Rows.Add(p.Properties[ParticipantProperty.Name].ToString(), "Yes", GetNow(), ""); } needUpdated = true; }
/// <summary> /// Handles event raised when a participant is added to meeting. If waiting in lobby, adds /// user name to lobby list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void _Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { //Watch for changes in participant property (IsInLobby) e.Participant.PropertyChanged += Participant_PropertyChanged; bool isInLobby = false; try { isInLobby = (bool)e.Participant.Properties[ParticipantProperty.IsInLobby]; } catch (System.NullReferenceException) { } //Check to see if participant is in lobby now if (isInLobby == true) { //Add the user's name to the lobby listbox this.Dispatcher.Invoke( new LoadListBoxDelegate(LoadListBox), new object[] { Lobby_ListBox, e.Participant.Contact.GetContactInformation(ContactInformationType.DisplayName).ToString() }); } else { //MeetingRoster_Listbox //Add the user's name to the lobby listbox this.Dispatcher.Invoke( new LoadListBoxDelegate(LoadListBox), new object[] { MeetingRoster_Listbox, e.Participant.Contact.GetContactInformation(ContactInformationType.DisplayName).ToString() }); } }
void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { // add event handlers for modalities of participants other than self participant: if (e.Participant.IsSelf == false) { if (((Conversation)sender).Modalities.ContainsKey(ModalityTypes.InstantMessage)) { ((InstantMessageModality)e.Participant.Modalities[ModalityTypes.InstantMessage]).InstantMessageReceived += new EventHandler <MessageSentEventArgs>(ConversationTest_InstantMessageReceived); ((InstantMessageModality)e.Participant.Modalities[ModalityTypes.InstantMessage]).IsTypingChanged += new EventHandler <IsTypingChangedEventArgs>(ConversationTest_IsTypingChanged); } Conversation conversation = (Conversation)sender; InstantMessageModality imModality = (InstantMessageModality)conversation.Modalities[ModalityTypes.InstantMessage]; string messageContent = "Hello World"; IDictionary <InstantMessageContentType, string> formattedMessage = this.GenerateFormattedMessage(messageContent); try { if (imModality.CanInvoke(ModalityAction.SendInstantMessage)) { IAsyncResult asyncResult = imModality.BeginSendMessage( formattedMessage, SendMessageCallback, imModality); } } catch (LyncClientException ex) { txtErrors.Text = ex.Message; } } }
void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { if (((Conversation)sender).Modalities.ContainsKey(ModalityTypes.InstantMessage)) { ((InstantMessageModality)e.Participant.Modalities[ModalityTypes.InstantMessage]).InstantMessageReceived += LyncHMessageRecorder_InstantMessageReceived; } }
void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { // add event handlers for modalities of participants other than self participant: if (e.Participant.IsSelf == false) { if (((Conversation)sender).Modalities.ContainsKey(ModalityTypes.InstantMessage)) { ((InstantMessageModality)e.Participant.Modalities[ModalityTypes.InstantMessage]).InstantMessageReceived += new EventHandler <MessageSentEventArgs>(ConversationTest_InstantMessageReceived); ((InstantMessageModality)e.Participant.Modalities[ModalityTypes.InstantMessage]).IsTypingChanged += new EventHandler <IsTypingChangedEventArgs>(ConversationTest_IsTypingChanged); } Conversation conversation = (Conversation)sender; InstantMessageModality imModality = (InstantMessageModality)conversation.Modalities[ModalityTypes.InstantMessage]; IDictionary <InstantMessageContentType, string> textMessage = new Dictionary <InstantMessageContentType, string>(); textMessage.Add(InstantMessageContentType.PlainText, "Hello World"); if (imModality.CanInvoke(ModalityAction.SendInstantMessage)) { IAsyncResult asyncResult = imModality.BeginSendMessage( textMessage, SendMessageCallback, imModality); } } }
void Conversation_ParticipantAdded(Object sender, ParticipantCollectionChangedEventArgs e) { Conversation conversation = sender as Conversation; Participant participant = e.Participant as Participant; //for this, not a new conversation.... if (conversation.Participants.Count > 2) { participantManager.IsShowWelcome = false; } else { participantManager.IsShowWelcome = true; } // add event handlers for modalities of participants other than self participant: if (participant.IsSelf == false) { var messagecontroller = participantManager.AddParticipant(participant.Contact.Uri, conversation, participant); if (conversation.Modalities.ContainsKey(ModalityTypes.InstantMessage)) { ((InstantMessageModality)participant.Modalities[ModalityTypes.InstantMessage]).InstantMessageReceived += new EventHandler <MessageSentEventArgs>(messagecontroller.ReceiveMessage); ((InstantMessageModality)participant.Modalities[ModalityTypes.InstantMessage]).IsTypingChanged += new EventHandler <IsTypingChangedEventArgs>(messagecontroller.TypeingChanged); } } }
private void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { if (e.Participant.IsSelf == false) { var imModality = (InstantMessageModality)e.Participant.Modalities[ModalityTypes.InstantMessage]; imModality.InstantMessageReceived += ImModality_InstantMessageReceived; } }
/// <summary> /// Called by the Lync SDK when a new participant is added to the conversation. /// </summary> private void conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs args) { //subscribes to messages sent only by a remote participant. if (args.Participant.IsSelf == false) { SubcribeToParticipantMessages(args.Participant); } }
void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { if (e.Participant.IsSelf == false) { if (((Conversation)sender).Modalities.ContainsKey(ModalityTypes.InstantMessage)) { ((InstantMessageModality)e.Participant.Modalities[ModalityTypes.InstantMessage]).InstantMessageReceived += new EventHandler<MessageSentEventArgs>(Page_InstantMessageReceived); } } }
void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { if (e.Participant.IsSelf == false) { if (((Conversation)sender).Modalities.ContainsKey(ModalityTypes.InstantMessage)) { ((InstantMessageModality)e.Participant.Modalities[ModalityTypes.InstantMessage]).InstantMessageReceived += new EventHandler <MessageSentEventArgs>(Page_InstantMessageReceived); } } }
void _onParticipantAdded(object sender, ParticipantCollectionChangedEventArgs ea) { System.Console.WriteLine("part added"); // if (ea.Participant.IsSelf) return; EventHandler <MessageSentEventArgs> onMessageReceived = (s, e) => _onMessageReceived(s, e, ea.Participant); (ea.Participant.Modalities[ModalityTypes.InstantMessage] as InstantMessageModality).InstantMessageReceived -= onMessageReceived; (ea.Participant.Modalities[ModalityTypes.InstantMessage] as InstantMessageModality).InstantMessageReceived += onMessageReceived; }
private static void PartiAded(object sender, ParticipantCollectionChangedEventArgs e) { if (e.Participant.IsSelf == false) { if (((Conversation)sender).Modalities.ContainsKey(ModalityTypes.InstantMessage)) { ((InstantMessageModality)e.Participant.Modalities[ModalityTypes.InstantMessage]).InstantMessageReceived += ChatRecived; } } }
/// <summary> /// ParticipantAdded callback handles ParticpantAdded event raised by Conversation /// </summary> /// <param name="source">Conversation Source conversation.</param> /// <param name="data">ParticpantCollectionEventArgs Event data</param> void Conversation_ParticipantAdded(Object source, ParticipantCollectionChangedEventArgs data) { if (data.Participant.IsSelf == false) { if (((Conversation)source).Modalities.ContainsKey(ModalityTypes.InstantMessage)) { //((InstantMessageModality)data.Participant.Modalities[ModalityTypes.InstantMessage]).InstantMessageReceived += myInstantMessageModality_MessageReceived; //((InstantMessageModality)data.Participant.Modalities[ModalityTypes.InstantMessage]).IsTypingChanged += myInstantMessageModality_ComposingChanged; } } }
void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { // add event handlers for modalities of participants other than self participant: if (e.Participant.IsSelf == false) { if (((Conversation)sender).Modalities.ContainsKey(ModalityTypes.InstantMessage)) { ((InstantMessageModality)e.Participant.Modalities[ModalityTypes.InstantMessage]).InstantMessageReceived += ConversationTest_InstantMessageReceived; } } }
/// <summary> /// Handles the event raised when a particpant is removed from the conversation. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void _conversation_ParticipantRemoved(object sender, ParticipantCollectionChangedEventArgs e) { //get the application sharing modality of the removed participant out of the class modalty dicitonary ApplicationSharingModality removedModality = _participantSharingModalities[e.Participant.Contact.Uri]; //Un-register for modality events on this participant's application sharing modality. removedModality.ActionAvailabilityChanged -= _sharingModality_ActionAvailabilityChanged; //Remove the modality from the dictionary. _participantSharingModalities.Remove(e.Participant.Contact.Uri); this.Invoke(new RemoveAContactDelegate(RemoveAContact), new object[] { e.Participant.Contact.Uri }); }
private void OnConversationParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { RunAtUI (() => { var newPart = e.Participant; var newModel = CreateAndInitParticipant(newPart); ParticipantCollection.AddItem(newModel); _log.Debug("OnConversationParticipantAdded uri:{0}", newPart.Contact.Uri); InvokePartConversationParticipantAdded(newModel); } ); }
private void OnConversationParticipantRemoved(object sender, ParticipantCollectionChangedEventArgs e) { RunAtUI (() => { var removePart = ParticipantCollection.Remove(e.Participant.Contact.Uri); InvokePartConversationParticipantRemoved(removePart); _log.Debug("OnConversationParticipantRemoved uri:{0}", removePart.Participant.Contact.Uri); } ); }
private void ParticipantRemoved(object sender, ParticipantCollectionChangedEventArgs e) { var participant = e.Participant; if (participant.IsSelf) { return; } var instantMessageModality = e.Participant.Modalities[ModalityTypes.InstantMessage] as InstantMessageModality; instantMessageModality.InstantMessageReceived -= InstantMessageReceived; }
private void conversation_ParticipantRemoved(object sender, ParticipantCollectionChangedEventArgs e) { Participant otherParty = e.Participant; if (!e.Participant.IsSelf) { if (otherParty.Modalities.ContainsKey(ModalityTypes.InstantMessage) && otherParty.Modalities[ModalityTypes.InstantMessage] != null) { var imModality = (InstantMessageModality)otherParty.Modalities[ModalityTypes.InstantMessage]; imModality.InstantMessageReceived -= new EventHandler <MessageSentEventArgs>(conversation_InstantMessageReceived); } } }
static void conversation_ParticipantAdded(object source, ParticipantCollectionChangedEventArgs data) { if (data.Participant.IsSelf != true) { if (((Conversation)source).Modalities[ModalityTypes.AudioVideo].CanInvoke(ModalityAction.Connect)) { object[] asyncState = { ((Conversation)source).Modalities[ModalityTypes.AudioVideo], "CONNECT" }; ((Conversation)source).Modalities[ModalityTypes.AudioVideo].ModalityStateChanged += avModality_ModalityStateChanged; ((Conversation)source).Modalities[ModalityTypes.AudioVideo].BeginConnect(EndConnect, asyncState); } } }
/// <summary> /// ParticipantAdded callback handles ParticpantAdded event raised by Conversation /// </summary> /// <param name="source">Conversation Source conversation.</param> /// <param name="data">ParticpantCollectionEventArgs Event data</param> void Conversation_ParticipantAdded(Object source, ParticipantCollectionChangedEventArgs data) { if (data.Participant.IsSelf == false) { //****************************************************************************** //wantedInformation is a dictionary that contains the types of contact information //that this sample application is interested in. You must specify which contact //information you want updates for in order to receive those updates. // //You can declare one dictionary for all contacts or a unique instance of the dictionary //for each contact you are interested in. With a unique dictionary, you can specify //different contact information types for individual contacts. //****************************************************************************** List <ContactInformationType> wantedInformation = new List <ContactInformationType>(); wantedInformation.Add(ContactInformationType.SourceNetwork); wantedInformation.Add(ContactInformationType.Capabilities); wantedInformation.Add(ContactInformationType.Availability); //*********************************************************** //canReceiveFormattedIM is a helper method in this class that //looks at the published Capabilities information of a contact //to see if that contact is capable of getting and sending IM. //*********************************************************** _FormatMessageAsText = canReceiveFormattedIM(data.Participant.Contact.GetContactInformation(wantedInformation)); if (((Conversation)source).Modalities.ContainsKey(ModalityTypes.InstantMessage)) { data.Participant.ActionAvailabilityChanged += new EventHandler <ParticipantActionAvailabilityChangedEventArgs>(Participant_ActionAvailabilityChanged); _RemoteIMModality = data.Participant.Modalities[ModalityTypes.InstantMessage] as InstantMessageModality; _RemoteIMModality.InstantMessageReceived += myInstantMessageModality_MessageReceived; _RemoteIMModality.IsTypingChanged += myInstantMessageModality_ComposingChanged; _RemoteIMModality.ActionAvailabilityChanged += new EventHandler <ModalityActionAvailabilityChangedEventArgs>(_RemoteIMModality_ActionAvailabilityChanged); _Conversation.Modalities[ModalityTypes.InstantMessage].ActionAvailabilityChanged += _RemoteIMModality_ActionAvailabilityChanged; _RemoteIMModality.ModalityStateChanged += myInstantMessageModality_ModalityStateChanged; _Conversation.Modalities[ModalityTypes.InstantMessage].ModalityStateChanged += myInstantMessageModality_ModalityStateChanged; this.Dispatcher.Invoke(FormActor, new object[] { FormActions.UpdateLabel, this.ActivityText_Label, "Participant Added" }); this.Dispatcher.Invoke(FormActor, new object[] { FormActions.EnableButton, Send_Button, null }); } } else { _LocalIMModality = data.Participant.Modalities[ModalityTypes.InstantMessage] as InstantMessageModality; _LocalIMModality.InstantMessageReceived += myInstantMessageModality_MessageReceived; } }
private void ParticipantRemoved(object sender, ParticipantCollectionChangedEventArgs e) { foreach (DataRow dr in dtPar.Rows) { if (dr["Displayname"].ToString() == e.Participant.Properties[ParticipantProperty.Name].ToString()) { dr["LeftTime"] = GetNow(); //Console.WriteLine("Left Time:%s", dr["LeftTime"]); } } dtPar.AcceptChanges(); needUpdated = true; //dtPar. }
private void ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs args) { try { var messageInfo = (InstantMessageModality)args.Participant.Modalities[ModalityTypes.InstantMessage]; // subscribe to event for new messages from this participant messageInfo.InstantMessageReceived += MessageReceived; } catch (Exception ex) { LogException("ParticipantAdded", ex); throw; } }
/// <summary> /// Called when a participant is added to the conversation. /// /// Adds the participant to the roster listbox. /// </summary> void conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { //error case, the participant wasn't actually added if (e.StatusCode < 0) { Console.Out.WriteLine("Participant was not added: code=" + e.StatusCode); return; } //posts the execution into the UI thread this.BeginInvoke(new MethodInvoker(delegate() { //creates a new item and adds to the roster listbox listBoxRosterContacts.Items.Add(new ParticipantItem(e.Participant)); })); }
private void Participant_StateChanged(object sender, ParticipantCollectionChangedEventArgs e) { bool external = false; var x = e.Participant.Contact.Uri; if (x.Substring(0, 3) == "sip") { Console.WriteLine("Internal Paticipant :" + x + " Added to Conversation" + e.Participant.Conversation.Properties[ConversationProperty.Id]); } else { if (e.Participant.Conversation.Modalities[ModalityTypes.AudioVideo].State == ModalityState.Connected) { ActiveAudioCalls.Add(e.Participant.Conversation.Properties[ConversationProperty.Id].ToString()); ActiveExternalAudioCalls.Add(e.Participant.Conversation.Properties[ConversationProperty.Id].ToString()); } else { ActiveExternalAudioCalls.Add(e.Participant.Conversation.Properties[ConversationProperty.Id].ToString()); Console.WriteLine("External Paticipant:" + x + " Added to Conversation" + e.Participant.Conversation.Properties[ConversationProperty.Id]); } } ExternalStatusChanged(); //var x = e.Participant.Contact.Uri; ////if (!bool.Parse(participant.Properties[ParticipantProperty.IsAuthenticated].ToString())) ////{ //// external = false; ////} //Console.WriteLine("PartAdded ID:" + e.Participant.Conversation.Properties[ConversationProperty.Id] + ": Name :" + x); //if (external) //{ // Console.WriteLine("External Call"); //} //else //{ // Console.WriteLine("Internal Call"); //} //throw new NotImplementedException(); }
private void conversation_ParticipantRemoved(object sender, ParticipantCollectionChangedEventArgs e) { var otherParty = e.Participant; if (e.Participant.IsSelf) { return; } if (!otherParty.Modalities.ContainsKey(ModalityTypes.InstantMessage) || otherParty.Modalities[ModalityTypes.InstantMessage] == null) { return; } var imModality = (InstantMessageModality)otherParty.Modalities[ModalityTypes.InstantMessage]; imModality.InstantMessageReceived -= conversation_InstantMessageReceived; }
void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { // if this is the remote participant then lets connect the ContentSharing modality. if (e.Participant.IsSelf != true) { _contentModality = (ContentSharingModality)((Conversation)sender).Modalities[ModalityTypes.ContentSharing]; if (_contentModality.CanInvoke(ModalityAction.Connect)) { try { _contentModality.BeginConnect(HandleCallBacks, "Connect"); } catch (Exception ec) { dispatcher.BeginInvoke(new Action <string>(Log), ec.ToString()); } } } }
/// <summary> /// 联系人移除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { try { //使用异步委托 Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (Add_ConversationParticalCallBack != null) { Add_ConversationParticalCallBack(e.Participant); } })); } catch (Exception ex) { LogManage.WriteLog(typeof(LyncHelper), ex); } finally { } }
private void conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { throw new NotImplementedException(); }
private void ParticipantRemoved(object sender, ParticipantCollectionChangedEventArgs args) { RemoveParticipant(args.Participant); }
void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { var participant = e.Participant; // We're not interested in notifying on our own IM's, so return if (participant.IsSelf) return; // Get the InstantMessage modality, and register to the InstantMessageReceived event var imModality = (InstantMessageModality)e.Participant.Modalities[ModalityTypes.InstantMessage]; imModality.InstantMessageReceived += ImModality_InstantMessageReceived; }
private void Conv_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { RefreshConversations(); }
private void conversation_ParticipantRemoved(object sender, ParticipantCollectionChangedEventArgs e) { Participant otherParty = e.Participant; if (!e.Participant.IsSelf) { if (otherParty.Modalities.ContainsKey(ModalityTypes.InstantMessage) && otherParty.Modalities[ModalityTypes.InstantMessage] != null) { var imModality = (InstantMessageModality)otherParty.Modalities[ModalityTypes.InstantMessage]; imModality.InstantMessageReceived -= new EventHandler<MessageSentEventArgs>(conversation_InstantMessageReceived); } } }
private static void conversation_ParticipantAdded(object source, ParticipantCollectionChangedEventArgs data) { if (data.Participant.IsSelf != true) { if (((Conversation)source).Modalities[ModalityTypes.AudioVideo].CanInvoke(ModalityAction.Connect)) { object[] asyncState = { ((Conversation)source).Modalities[ModalityTypes.AudioVideo], "CONNECT" }; ((Conversation)source).Modalities[ModalityTypes.AudioVideo].ModalityStateChanged += avModality_ModalityStateChanged; ((Conversation)source).Modalities[ModalityTypes.AudioVideo].BeginConnect(EndConnect, asyncState); } } }