public override bool NewMessage(Message iq) { /// See if this is a standard text message /// if (iq is ChatMessage) { ChatMessage chatmsg = iq as ChatMessage; RosterItem item = XMPPClient.FindRosterItem(chatmsg.From); if (item != null) { if (chatmsg.Body != null) { TextMessage txtmsg = new TextMessage(); txtmsg.From = chatmsg.From; txtmsg.To = chatmsg.To; txtmsg.Received = DateTime.Now; if (chatmsg.Delivered.HasValue == true) txtmsg.Received = chatmsg.Delivered.Value; /// May have been a server stored message txtmsg.Message = chatmsg.Body; txtmsg.Sent = false; item.AddRecvTextMessage(txtmsg); item.HasNewMessages = true; // Notify XMPPClient that a new conversation item has been added XMPPClient.FireNewConversationItem(item, true, txtmsg); } if (chatmsg.ConversationState != ConversationState.none)// A conversation message { item.Conversation.ConversationState = chatmsg.ConversationState; XMPPClient.FireNewConversationState(item, item.Conversation.ConversationState); } } return true; } return false; }
public virtual bool NewMessage(Message iq) { return false; }
public override bool NewMessage(Message iq) { return base.NewMessage(iq); }
public override bool NewMessage(Message iq) { try { if (iq.GetType() == MessageType) { RecvMessage = iq; IsCompleted = true; Success = true; GotEvent.Set(); return true; } } catch (Exception) { } return false; }
public override bool NewMessage(Message iq) { /// Look for pubsub events /// if (iq is PubSubEventMessage) { PubSubEventMessage psem = iq as PubSubEventMessage; if (psem.Event != null) { if ((psem.Event.Items != null) && (psem.Event.Items.Items != null) && (psem.Event.Items.Items.Length > 0)) { PubSubItem psitem = psem.Event.Items.Items[0]; XElement elem = psitem.InnerItemXML as XElement; if (psem.Event.Items.Node == "http://jabber.org/protocol/tune") { TuneItem item = psitem.GetObjectFromXML<TuneItem>(); if (item != null) { /// find the roster item, set the tune item RosterItem rosteritem = XMPPClient.FindRosterItem(iq.From); if (rosteritem != null) { rosteritem.Tune = item; } } } else if (psem.Event.Items.Node == "http://jabber.org/protocol/geoloc") { geoloc item = psitem.GetObjectFromXML<geoloc>(); if (item != null) { /// find the roster item, set the tune item RosterItem rosteritem = XMPPClient.FindRosterItem(iq.From); if (rosteritem != null) { rosteritem.GeoLoc = item; } } } else if (psem.Event.Items.Node == "http://jabber.org/protocol/mood") { } else if (psem.Event.Items.Node == "urn:xmpp:avatar:metadata") /// item avatar metadata { /// We have update avatar info for this chap, we should then proceed to get the avatar data /// foreach (PubSubItem objItem in psem.Event.Items.Items) { avatarmetadata meta = psitem.GetObjectFromXML<avatarmetadata>(); if (meta != null) { /// Request this node ? maybe we get it automatically? /// } /// Not sure why they would have more than 1 avatar item, so we'll ignore fom now /// break; } } else if (psem.Event.Items.Node == "urn:xmpp:avatar:data") /// item avatar { /// We have update avatar info for this chap, we should then proceed to get the avatar data /// /// Works, but let's comment out for now to focus on more supported avatar methods //foreach (PubSubItem objItem in psem.Items) //{ // avatardata data = Utility.ParseObjectFromXMLString(objItem.InnerItemXML, typeof(avatardata)) as avatardata; // if (data != null) // { // string strHash = XMPPClient.AvatarStorage.WriteAvatar(data.ImageData); // RosterItem item = XMPPClient.FindRosterItem(psem.From); // if (item != null) // { // item.AvatarImagePath = strHash; // } // } // /// Not sure why they would have more than 1 avatar item, so we'll ignore fom now // /// // break; //} } } } } return base.NewMessage(iq); }