Exemplo n.º 1
0
		public static Stanza GetStanza(XmlNode xml) 
		{
			Stanza s = null;
			switch(xml.Name)
			{
				case "iq":
					s = new IQStanza(xml);
					break;
				case "message":
					s = new MessageStanza(xml);
					break;
				case "presence":
					s = new PresenceStanza(xml);
					break;
				default:
					s = new Stanza(xml);
					break;
			}
			return s;
		}
Exemplo n.º 2
0
		private void onPresenceStanzaReceived(PresenceStanza s)
		{
			string[] tokens = s.From.Split('/');
			Contact c = null;

			switch(s.Type)
			{
				case "subscribe":
					DialogResult res = MessageBox.Show(this, s.From+" is adding you to his roster.  Is this OK?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
					session.SendStanza(StanzaFactory.GetReplySubscriptionRequestStanza(s.From, res == DialogResult.Yes));
					break;
				case "subscribed":
					// TODO
					break;
				case "unsubscribe":
					// TODO
					break;
				case "unsubscribed":
					// TODO
					break;
				case "unavailable":
					c = roster[tokens[0]] as Contact;
					if(c != null) c.Resources.Clear();
					refreshRosterView();
					break;
				default:
					// Someone has logged in so update their information
					c = roster[tokens[0]] as Contact;
					if(c != null)
					{
						if(!c.Resources.Contains(tokens[1])) c.Resources.Add(tokens[1]);
						refreshRosterView();
					}
					break;
			}
		}