Not logged in. · Lost password · Register
Forum: MatriX Mobile (Compact Framework) RSS
jmaines2 #1
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
Subject: How do I register a new account programmatically?
I'd like to have my application self-register. 

Here's what I'm attempting to do: I have a user ID that may or may not exist on the Jabber server already.
The Jabber server that I am connecting to is setup to allow for auto-registry.
I'd like to check if the account exists and if not, auto-register the account.
I'm assuming that I'd use something like xmppClient.RegisterNewAccount.

Are there parameters that need to be passed in?
Could you provide me with a quick code snippet on how to do something like this?

Thanks in advance.
Avatar
Alex #2
Member since Feb 2003 · 2570 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by jmaines2:
I'd like to have my application self-register. 

Here's what I'm attempting to do: I have a user ID that may or may not exist on the Jabber server already.
The Jabber server that I am connecting to is setup to allow for auto-registry.
I'd like to check if the account exists and if not, auto-register the account.
I'm assuming that I'd use something like xmppClient.RegisterNewAccount.
yes this is how it works. If you can't register because the account is already in use or the server supports no registration you get the OnRegisterError event. On Success you get the OnRegisterEvent.

Quote by jmaines2:
Are there parameters that need to be passed in?
Could you provide me with a quick code snippet on how to do something like this?
In the OnRegisterInformation event you must set the registration fields like username, password, email...

here is an example:
  1. private void xmppClient_OnRegisterInformation(object sender, RegisterEventArgs e)
  2. {
  3.     e.Register.RemoveAll<Data>();
  4.    
  5.     e.Register.Username = xmppClient.Username;
  6.     e.Register.Password = xmppClient.Password;
  7. }
  8.  
  9. private void xmppClient_OnRegister(object sender, EventArgs e)
  10. {
  11.     // success
  12. }
  13.  
  14. private void xmppClient_OnRegisterError(object sender, IqEventArgs e)
  15. {
  16.     // error
  17.     xmppClient.Close();
  18. }

Alex
Alexander Gnauck
AG-Software
jmaines2 #3
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
Thanks so much for the help Alex. Hopefully, the company I'm doing this work for will purchase Matrix within the next week.
jmaines2 #4
Member since Feb 2010 · 13 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #2
Quote by Alex:
In the OnRegisterInformation event you must set the registration fields like username, password, email...

here is an example:
  1. private void xmppClient_OnRegisterInformation(object sender, RegisterEventArgs e)
  2. {
  3.     e.Register.RemoveAll<Data>();
  4.    
  5.     e.Register.Username = xmppClient.Username;
  6.     e.Register.Password = xmppClient.Password;
  7. }

Alex

What should I be replacing "Data" with? I'm getting the following message when I use the code as-is:
"The type or namespace name 'Data' could not be found (are you missing a using directive or an assembly reference?)"
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: