Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
jzp_cn #1
Member since Aug 2005 · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: how register a jabber account with agsXMPP
this code don't register a account!

  1. protected bool connect()
  2.         {
  3.             XmppCon = null;
  4.  
  5.             // connected to the server
  6.             string  server    = "jabber.org";
  7.             int  port = 5222;    
  8.  
  9.             //
  10.             XmppCon = new XmppClientConnection();
  11.             XmppCon.OnReadXml      += new XmlHandler(XmppCon_OnReadXml);
  12.             XmppCon.OnWriteXml    += new XmlHandler(XmppCon_OnWriteXml);
  13.             XmppCon.OnRegistered    += new ObjectHandler(XmppCon_OnRegistered);
  14.            
  15.             // connect to server       
  16.             XmppCon.Server  = server;
  17.             XmppCon.Port    = port;
  18.             try
  19.             {
  20.                 XmppCon.Open();
  21.             }
  22.             catch(Exception ex)
  23.             {
  24.                 Console.WriteLine("Error:" + ex.Message);
  25.                 return false;
  26.             }
  27.  
  28.             //
  29.             return true;
  30.         }
  31.        
  32.         public bool register(string jid)
  33.         {
  34.             //
  35.             if((XmppCon == null) || (XmppCon.ConnectionState != XmppConnectionState.Connected))
  36.             {
  37.                 if (!connect())
  38.                 {
  39.                     Console.WriteLine("Connect jabber server failed!");
  40.                     return false;
  41.                 }         
  42.             }         
  43.  
  44.             //
  45.             //agsXMPP.protocol.client.Stream stream = new Stream();   
  46.             //stream.To = new Jid("jabber.org");
  47.             //stream.Namespace ="xmlns='jabber.org' xmlns:stream='http://etherx.jabber.org/streams'" ;
  48.             //stream.Version = "1.0";
  49.             //agsXMPP.protocol.iq.register.RegisterIq regIQ = new agsXMPP.protocol.iq.register.RegisterIq();
  50.             agsXMPP.protocol.iq.register.Register reg = new agsXMPP.protocol.iq.register.Register("ppp", "111111");
  51.             //agsXMPP.protocol.client.Message msg
  52.            
  53.             //
  54.             //agsXMPP.protocol.client.Message msg = new Message;
  55.             //msg.Type = MessageType.normal;
  56.            
  57.  
  58.            
  59.  
  60.            
  61.             //   
  62.             try
  63.             {
  64.                 XmppCon.Send(reg);
  65.             }
  66.             catch(Exception ex)
  67.             {
  68.                 Log.Info("SND Exception:" + ex.Message);
  69.                 return false;
  70.             }
  71.  
  72.             //
  73.             return true;
  74.         }
This post was edited on 2006-02-17, 21:21 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi,

the lib has built in register support. You have to set the RegisterAccount property to true before you connect. The lib tries to register the new account and logins with this account after success.
OnRegistered is raised when the account was created successful
OnRegisterError is called on errors.

Alex
Avatar
Alex #3
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
i updated the MiniClient Sample. Please check it out again. In the Login form is a new checkbox for registering accounts now.

Alex
Avatar
52xx #4
Member since Sep 2005 · 20 posts
Group memberships: Members
Show profile · Link to this post
i have used your mini-client to know the way to login, and other function.now,however, i failed !
i login into the jabber.com.cn, but nothing happened after that. and i have no .sln document.
could you give me a well mini-client ?
Avatar
Alex #5
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by "52xx":
i have used your mini-client to know the way to login, and other function.now,however, i failed !
i login into the jabber.com.cn, but nothing happened after that. and i have no .sln document.
could you give me a well mini-client ?
Take the csproj file. The sln file is created automatically by visual studio.
Click on the File->Connect menu and enter the username you wanna register and the password for this username.

Example:
You want to register the username test on the the server jabber.org, then enter test@jabber.org in the Jid field. And make sure that the checkbox register new Account is checked. When you click on Login now the Lib first registers the account when possible, and after that logins with the new account.

Alex
Avatar
preky #6
Member since Jan 2006 · 17 posts
Group memberships: Members
Show profile · Link to this post
I have downloaded source for MiniClient on link
http://www.ag-software.net/index.php?option=content&ta…
but Login form doesn't have checkbox for register new account and the code needed for that action. Can you provide link to that version, please?

Thx!
Preky
Avatar
Alex #7
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi Perky,

this will be in the next release of the MiniClient.
just add the checkbox yourself and set the RegisterAccount property to true before connecting.

Alex
Avatar
preky #8
Member since Jan 2006 · 17 posts
Group memberships: Members
Show profile · Link to this post
Can you please post code linked to that problem?
Preky
Avatar
Alex #9
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Please contact me by private mail and i will send you the new sample code. I also updated the registration stuff in the library some days ago to be fully xmpp compliant.
But im currently out of the office and will send you the code later in the evening.

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