Not logged in. · Lost password · Register
Forum: XMPP Protocol RSS
Avatar
lsharma #1
Member since Feb 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: how to connect to xmpp server
hello experts,

i want to build an application that will connect to xmpp server and allow users to do voice and text chat...
my first tasks is straight forward... i am using dotnet... how can i connect to xmpp.. i have installed openfire on my local network..192.168.0.58, i guess it works on 5222 port....

  1. protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             string uri = "http://chd-wrkstn-043:5222";
  4.             string fileName = Server.MapPath("test.xml");
  5.             WebRequest req = WebRequest.Create(uri);
  6.             req.Method = "POST";
  7.            
  8.             req.ContentType = "text/xml";
  9.             //req.ContentLength = 790;
  10.             StreamWriter strw = new StreamWriter(req.GetRequestStream());
  11.             strw.Write(GetTextFromXMLFile(fileName));
  12.             strw.Close();
  13.             WebResponse resp = req.GetResponse();
  14.             StreamReader sr = new StreamReader(resp.GetResponseStream());
  15.  
  16.             string a = sr.ReadToEnd().ToString();
  17.             sr.Close();
  18.             string str = resp.Headers.ToString();
  19.             string ssd = resp.ResponseUri.ToString();
  20.         }
  21.  
  22.         private string GetTextFromXMLFile(string file)
  23.         {
  24.             StreamReader reader = new StreamReader(file);
  25.             string ret = reader.ReadToEnd();
  26.             reader.Close();
  27.             return ret;
  28.         }

XML file

<iq to='chd-wrkstn-043'
    type='set'
    id='sess_1'>
  <session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>
</iq>


i know i maybe completely wrong...but i cant find a wayout of this problem...
This post was edited on 2012-01-31, 19:41 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Download one of our libraries and connect? They do all the hard work for you.

Alex
Avatar
lsharma #3
Member since Feb 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
Hello Alex,

I did download one agsxmpp... but couldnt get any help... the documentation lists a bundle of classes which are quite confusing... the sample has sytax for making connection... so how would i send message to the other user... and also wht abt voice chat... what classes are used to handle these tasks..
thats why i started with creating my own....
i guess we only need to post the xml on openfire... and it shd do the rest... so whts the way to connect to openfire... without any of the above library
This post was edited on 2011-02-18, 06:58 by lsharma.
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by lsharma:
I did download one agsxmpp... but couldnt get any help... the documentation lists a bundle of classes which are quite confusing... the sample has sytax for making connection... so how would i send message to the other user...

please study the MiniClient example. There is all you need.

Quote by lsharma:
and also wht abt voice chat... what classes are used to handle these tasks
this is not included. You have to extend agsXMPP for the XMPP Jingle protocols.

Alex
Avatar
Alex #5
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #3
Quote by lsharma:
i guess we only need to post the xml on openfire... and it shd do the rest... so whts the way to connect to openfire... without any of the above library
you are totally wrong.

See:
http://xmpp.org/internet-drafts/draft-ietf-xmpp-3920bis-13…
http://xmpp.org/internet-drafts/draft-ietf-xmpp-3921bis-12…
Avatar
lsharma #6
Member since Feb 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #3
hello alex,

i got some success.... actually the problem that i am facing is the CORRECT XML..... i guess that was the issue the code was not working...
now could pls help me on this... i'll be very thankful to you... can u pls correct the below xml format

<?xml version='1.0'?>
<stream:stream xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'
version='1.0'
to='asood@chd-wrkstn-043'>
<iq to='asood@chd-wrkstn-043'
    type='set'
    id='sess_1'>
  <session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>
</iq>
<presence>
  <show>dnd</show>
</presence>

<message
    to='asood@chd-wrkstn-043'
    from='lsharma@chd-wrkstn-043'
    type='chat'
    xml:lang='en'>
  <body>Wherefore art thou, Romeo?</body>
</message>

</stream:stream>
Avatar
lsharma #7
Member since Feb 2011 · 4 posts
Group memberships: Members
Show profile · Link to this post
hello alex,

thanx for all ur feedback..... could just provide me an xml...that will connect to server and post the username and password and allow me to send a message to another person
Avatar
Alex #8
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
As I said before, please use one of our libraries MatriX or agsXMPP for connecting to your Openfire server. Or any other library you prefer. Connecting to a XMPP sever is a complex task and much more than only sending a small XML snippets.

If you still want to wrote your own code then please study the RFCs which I mentioned in my previous post.
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: