Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
geovanyayala #1
Member since Jun 2007 · 5 posts · Location: Los Mochis, Sinaloa
Group memberships: Members
Show profile · Link to this post
Subject: Custom Packets +array
Hi again. i doing a custom packets iq type, i need send a receive custom types like clases or arrays. How can i do that?

thanks for your help and time
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

there are different way to achieve this.

  • You could serialize your classes with .NET to XML
  • XML-RPC over XMPP
  • SOAP over XMPP

Alex
Avatar
geovanyayala #3
Member since Jun 2007 · 5 posts · Location: Los Mochis, Sinaloa
Group memberships: Members
Show profile · Link to this post
Can you give me an example, i was trying to do it, but i can´t.

here is an example on xml serializable class

    [XmlRoot("foros")]
    public class ClaseForoSerializable
    {
        private ArrayList listaForos;

        public ClaseForoSerializable()
        {
            listaForos = new ArrayList();
        }

        [XmlElement("ForosA")]
        public ForosA[] Elementos
        {
            get
            {
                ForosA[] items = new ForosA[listaForos.Count];
                listaForos.CopyTo(items);
                return items;
            }
            set
            {
                if (value == null) return;
                ForosA[] items = (ForosA[])value;
                listaForos.Clear();
                foreach (ForosA item in items)
                    listaForos.Add(item);
            }
        }

        public int AddItem(ForosA item)
        {
            return listaForos.Add(item);
        }
    }

    public class ForosA
    {
        [XmlAttribute("clave")]
        public string clave;
        [XmlAttribute("descripcion")]
        public string descripcion;

        public ForosA()
        {
        }

        public ForosA(string Clave, string Descripcion)
        {
            clave = Clave;
            descripcion = Descripcion;
        }
    }

and this

public class Foros : Element
    {
        public Foros()
        {
            this.TagName = "forosabiertos";
            this.Namespace = "uas:forosabiertos";
        }
        /*private ClaseForoSerializable _ForosAbiertos;
        public ClaseForoSerializable ForosAbiertos
        {
            get { return _ForosAbiertos; }
            set { _ForosAbiertos = value; }
        }*/

        public ClaseForoSerializable ForosAbiertos
        {
            get { return (ClaseForoSerializable)GetTagEnum("ForosAbiertos", typeof(ClaseForoSerializable)); }
            set { SetTag(typeof(ClaseForoSerializable), value.ToString()); }   *********
        }
    }


so i have an error when execute the line with ****


Foros _foros = new Foros();
            ClaseForoSerializable cfs = new ClaseForoSerializable();
            cfs.AddItem(new ForosA("1", "1"));
            _foros.ForosAbiertos = cfs;
            Jid to = new Jid("servidoraplicaciones@geovany");
            agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
            msg.To = to;           
            msg.AddChild(_foros);******
           
            XmppCon.Send(msg);


what's happening.

thanks for your help
Avatar
Alex #4
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

agsXMPP is using its own XML parser and its own XML Dom. So you can't Mix MS XML stuff with agsXMPP XML stuff.
In this case you have to write out the MS XML to a string and parse it into agsXMPP Xml.

But i would suggest to study the agsXMPP source code. The most classes in agsXMPP are XML object. This means you can map you objects to classes like we did it with all XMPP objects.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS