Subject: how register a jabber account with agsXMPP
this code don't register a account!
- protected bool connect()
- {
- XmppCon = null;
- // connected to the server
- string server = "jabber.org";
- int port = 5222;
- //
- XmppCon = new XmppClientConnection();
- XmppCon.OnReadXml += new XmlHandler(XmppCon_OnReadXml);
- XmppCon.OnWriteXml += new XmlHandler(XmppCon_OnWriteXml);
- XmppCon.OnRegistered += new ObjectHandler(XmppCon_OnRegistered);
- // connect to server
- XmppCon.Server = server;
- XmppCon.Port = port;
- try
- {
- XmppCon.Open();
- }
- catch(Exception ex)
- {
- Console.WriteLine("Error:" + ex.Message);
- return false;
- }
- //
- return true;
- }
- public bool register(string jid)
- {
- //
- if((XmppCon == null) || (XmppCon.ConnectionState != XmppConnectionState.Connected))
- {
- if (!connect())
- {
- Console.WriteLine("Connect jabber server failed!");
- return false;
- }
- }
- //
- //agsXMPP.protocol.client.Stream stream = new Stream();
- //stream.To = new Jid("jabber.org");
- //stream.Namespace ="xmlns='jabber.org' xmlns:stream='http://etherx.jabber.org/streams'" ;
- //stream.Version = "1.0";
- //agsXMPP.protocol.iq.register.RegisterIq regIQ = new agsXMPP.protocol.iq.register.RegisterIq();
- agsXMPP.protocol.iq.register.Register reg = new agsXMPP.protocol.iq.register.Register("ppp", "111111");
- //agsXMPP.protocol.client.Message msg
- //
- //agsXMPP.protocol.client.Message msg = new Message;
- //msg.Type = MessageType.normal;
- //
- try
- {
- XmppCon.Send(reg);
- }
- catch(Exception ex)
- {
- Log.Info("SND Exception:" + ex.Message);
- return false;
- }
- //
- return true;
- }
This post was edited on 2006-02-17, 22:21 by Alex.