see. here am posting source code of connecting to nimbuzz server :-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using agsXMPP;
using agsXMPP.protocol.client;
using agsXMPP.Xml.Dom;
using agsXMPP.protocol.x.muc;
namespace server-bot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
}
XmppClientConnection x = new XmppClientConnection();
private void button1_Click(object sender, EventArgs e)
{
x = new XmppClientConnection {Show = agsXMPP.protocol.client.ShowType.chat, Server = "nimbuzz.com", ConnectServer = "o.nimbuzz.com",Status="send help to know how to use" };
x.Open( id.Text, password.Text, resource.Text);
x.OnLogin += new ObjectHandler(x_OnLogin);
x.OnMessage += new MessageHandler(x_OnMessage);
x.OnAuthError += new XmppElementHandler(x_OnAuthError);
x.OnError +=new ErrorHandler(x_OnError);
x.OnPresence += new PresenceHandler(x_OnPresence);
}
public void x_OnPresence(object sender, Presence prs)
{
if (prs.Type == PresenceType.subscribe)
{
x.Send(new Presence { To = prs.From, Type = PresenceType.subscribe });
x.Send(new Presence { To = prs.From, Type = PresenceType.subscribed });
((XmppClientConnection)sender).Send(new agsXMPP.protocol.client.Message { To =prs.From, Body = "send help", Type = MessageType.chat });
}
}
public void x_OnLogin(object sender)
{
id.BackColor = Color.Green;
password.BackColor = Color.Green;
x.SendMyPresence();
}
public void x_OnError(object sender,Exception ex)
{
id.BackColor = Color.Yellow;
password.BackColor = Color.Yellow;
x.Open( id.Text, password.Text, resource.Text);
}
public void x_OnAuthError(object sender, Element el)
{
id.BackColor = Color.Red;
password.BackColor = Color.Red;
}
public void x_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
{
try
{
if (msg.Body == null)
{
return;
}
else
{
msg.Body = msg.Body.ToLower().Trim();
}
if (msg.Body == "help")
{
((XmppClientConnection)sender).Send(new agsXMPP.protocol.client.Message { To = msg.From, Body = "send con#id#password#resource#room#roompassword ", Type = MessageType.chat });
}
if (msg.Body.StartsWith("con#"))
{
string[] arr = new string[]{};
arr = msg.Body.Split('#') ;