Subject: the problem of register
this is my code for register, but i cannot do it ,here is my code:
and here is my debug message:
hope for the anwser.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using agsXMPP.Collections;
using agsXMPP.protocol;
using agsXMPP;
using agsXMPP.Xml;
using agsXMPP.protocol.iq;
using agsXMPP.protocol.iq.roster;
using agsXMPP.protocol.iq.agent;
using agsXMPP.Xml.DomParser;
namespace agsxmpp_test
{
public partial class Registerss : Form
{
private XmppClientConnection laji;
public Registerss()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
agsXMPP.protocol.iq.register.Register reg = new agsXMPP.protocol.iq.register.Register(textBox1.Text, textBox2.Text);
laji.Send(reg);
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString());
}
}
private void laji_OnLogin(object sender)
{
txtDebug.Text += "we are logged in to the server now" + System.Environment.NewLine;
MessageBox.Show("we are logged in to the server now" + System.Environment.NewLine);
txtDebug.Text += "set presence" + System.Environment.NewLine;
txtDebug.SelectionStart = txtDebug.Text.Length;
txtDebug.ScrollToCaret();
laji.SendMyPresence();
}
private void laji_OnError(object sender, Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
}
private void laji_OnReadXml(object sender, string xml)
{
txtDebug.Text += "RECV XML: " + xml + System.Environment.NewLine;
txtDebug.SelectionStart = txtDebug.Text.Length;
txtDebug.ScrollToCaret();
}
private void laji_OnWriteXml(object sender, string xml)
{
txtDebug.Text += "SEND XML: " + xml + System.Environment.NewLine;
txtDebug.SelectionStart = txtDebug.Text.Length;
txtDebug.ScrollToCaret();
}
private void laji_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
{
txtDebug.Text += msg.Body.ToString() + "\r\n";
}
private void laji_OnRegistered(object sender)
{
txtDebug.Text += "register ok !"+"\r\n";
MessageBox.Show("register ok !");
}
private void Registerss_Load(object sender, EventArgs e)
{
laji = new XmppClientConnection();
laji.OnReadXml += new XmlHandler(laji_OnReadXml);
laji.OnWriteXml += new XmlHandler(laji_OnWriteXml);
laji.OnLogin += new ObjectHandler(laji_OnLogin);
laji.OnMessage += new XmppClientConnection.MessageHandler(laji_OnMessage);
laji.OnError += new ErrorHandler(laji_OnError);
laji.OnRegistered += new ObjectHandler(laji_OnRegistered);
laji.RegisterAccount = true;
laji.Server = "192.168.1.106";
laji.Port =5222;
laji.Open();
try
{
txtDebug.Text += "open success !" + "\r\n";
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using agsXMPP.Collections;
using agsXMPP.protocol;
using agsXMPP;
using agsXMPP.Xml;
using agsXMPP.protocol.iq;
using agsXMPP.protocol.iq.roster;
using agsXMPP.protocol.iq.agent;
using agsXMPP.Xml.DomParser;
namespace agsxmpp_test
{
public partial class Registerss : Form
{
private XmppClientConnection laji;
public Registerss()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
agsXMPP.protocol.iq.register.Register reg = new agsXMPP.protocol.iq.register.Register(textBox1.Text, textBox2.Text);
laji.Send(reg);
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString());
}
}
private void laji_OnLogin(object sender)
{
txtDebug.Text += "we are logged in to the server now" + System.Environment.NewLine;
MessageBox.Show("we are logged in to the server now" + System.Environment.NewLine);
txtDebug.Text += "set presence" + System.Environment.NewLine;
txtDebug.SelectionStart = txtDebug.Text.Length;
txtDebug.ScrollToCaret();
laji.SendMyPresence();
}
private void laji_OnError(object sender, Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
}
private void laji_OnReadXml(object sender, string xml)
{
txtDebug.Text += "RECV XML: " + xml + System.Environment.NewLine;
txtDebug.SelectionStart = txtDebug.Text.Length;
txtDebug.ScrollToCaret();
}
private void laji_OnWriteXml(object sender, string xml)
{
txtDebug.Text += "SEND XML: " + xml + System.Environment.NewLine;
txtDebug.SelectionStart = txtDebug.Text.Length;
txtDebug.ScrollToCaret();
}
private void laji_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
{
txtDebug.Text += msg.Body.ToString() + "\r\n";
}
private void laji_OnRegistered(object sender)
{
txtDebug.Text += "register ok !"+"\r\n";
MessageBox.Show("register ok !");
}
private void Registerss_Load(object sender, EventArgs e)
{
laji = new XmppClientConnection();
laji.OnReadXml += new XmlHandler(laji_OnReadXml);
laji.OnWriteXml += new XmlHandler(laji_OnWriteXml);
laji.OnLogin += new ObjectHandler(laji_OnLogin);
laji.OnMessage += new XmppClientConnection.MessageHandler(laji_OnMessage);
laji.OnError += new ErrorHandler(laji_OnError);
laji.OnRegistered += new ObjectHandler(laji_OnRegistered);
laji.RegisterAccount = true;
laji.Server = "192.168.1.106";
laji.Port =5222;
laji.Open();
try
{
txtDebug.Text += "open success !" + "\r\n";
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}
}
}
and here is my debug message:
version='1.0'>
open success !
RECV XML: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="192.168.1.101" id="d994741e" lang="en" >
SEND XML: <iq xmlns="jabber:client" id="agsXMPP_1" type="set" to="192.168.1.106"><query xmlns="jabber:iq:register"><username /><password /></query></iq>
RECV XML: <iq xmlns="jabber:client" type="error" id="agsXMPP_1" from="192.168.1.106" to="192.168.1.101/d994741e"><query xmlns="jabber:iq:register"><username /><password /></query><error code="406" type="modify"><not-acceptable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></iq>
SEND XML: <query xmlns="jabber:iq:register"><username>bbb</username><password>bbb</password></query>
RECV XML: </stream:stream>
open success !
RECV XML: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="192.168.1.101" id="d994741e" lang="en" >
SEND XML: <iq xmlns="jabber:client" id="agsXMPP_1" type="set" to="192.168.1.106"><query xmlns="jabber:iq:register"><username /><password /></query></iq>
RECV XML: <iq xmlns="jabber:client" type="error" id="agsXMPP_1" from="192.168.1.106" to="192.168.1.101/d994741e"><query xmlns="jabber:iq:register"><username /><password /></query><error code="406" type="modify"><not-acceptable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></iq>
SEND XML: <query xmlns="jabber:iq:register"><username>bbb</username><password>bbb</password></query>
RECV XML: </stream:stream>
hope for the anwser.