Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
lingx825 #1
Member since Nov 2007 · 23 posts
Group memberships: Members
Show profile · Link to this post
Subject: How to send a message in C#?
I'm a new in C# & agsXMPP
so after read the homepage instruction
I  try to send a message using agsXMPP
I start the openfire and login in spark as a receiver
Here is my console app as sender(they both subscribed )

namespace Test
{
    using agsXMPP;
    using agsXMPP.protocol.client;
    class Program
    {
        static void Main(string[] args)
        {
            XmppClientConnection xmpp = new XmppClientConnection("louis");
            xmpp.Open("mini", "mini");
            Message msg = new Message("spark@louis", MessageType.chat, "Hello, how are you?");
            xmpp.Send(msg);
            xmpp.Close();          
        }
    }
}
but when I run the console app,the receiver didn't show anything,why this happened?
then I enter the debug mode try to figure it out,
sometimes the receiver pop up the "Helllo,how are you"
sometimes not,I was confused...

Help~!
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you have to wait for the OnLogin event before you can send and receive messages.
This is why the example on our webpage looks like this:

  1. XmppClientConnection xmpp = new XmppClientConnection("jabber.org");
  2. xmpp.Open("myusername", "mysecret");
  3. xmpp.OnLogin += delegate(object o) { xmpp.Send(new Message("test@jabber.org", MessageType.chat, "Hello, how are you?")); };
Avatar
lingx825 #3
Member since Nov 2007 · 23 posts
Group memberships: Members
Show profile · Link to this post
Hello,Alex
Thanks for reply
I change the code

namespace Test
{
    using agsXMPP;
    using agsXMPP.protocol.client;
    class Program
    {
        static void Main(string[] args)
        {
            /*
            XmppClientConnection xmpp = new XmppClientConnection("louis");
            xmpp.Open("mini", "mini");          
            Message msg = new Message("spark@louis", MessageType.chat, "Hello, how are you?");           
            xmpp.Send(msg);
            xmpp.Close();
           */
            XmppClientConnection xmpp = new XmppClientConnection("louis");
            xmpp.Open("mini", "mini");
            xmpp.OnLogin += delegate(object o) { xmpp.Send(new Message("spark@louis", MessageType.chat, "Hello, how are you?")); };
       }
    }
}

But still nothing happend and I don't know how to debug..
Avatar
Jabberer #4
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
try to sleep some seconds at the end of your program, so it does not terminate immediately.
Please take a look at the examples in the sample directory and especially at the MiniClient application.
Software Developer
AG-Software
This post was edited on 2013-03-06, 19:16 by Alex.
Avatar
lingx825 #5
Member since Nov 2007 · 23 posts
Group memberships: Members
Show profile · Link to this post
Wooo~It works
I will try to create custom packet
Again,Thank you guys!
Avatar
rnbguy #6
Member since Dec 2007 · 3 posts
Group memberships: Members
Show profile · Link to this post
hi ,

im glad it worked for you, could you please share what you've done to fix the problem you were having, i have done this:


but it doesnt return loged in.


  1. XmppClientConnection xmpp = new XmppClientConnection("192.168.0.1");
  2.  
  3. xmpp.Open("xxxx", "xxx");
  4. xmpp.OnLogin += new ObjectHandler(xmpp_OnLogin);
  5.  
  6.  
  7. System.Threading.Thread.Sleep(5000);
  8.  
  9. MessageBox.Show("login failed");   
  10.  
  11.  
  12. void xmpp_OnLogin(object sender)
  13. {
  14.     MessageBox.Show("logged in");
  15. }
This post was edited 2 times, last on 2013-03-06, 19:17 by Alex.
Avatar
Alex #7
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
again:

never use IP addresses in XMPP. XMPP servers are always configured to domains and not to IP addresses. The domain part is also used in the SASL authentication and user ids. This is why your authentication fails.

Alex
Avatar
rnbguy #8
Member since Dec 2007 · 3 posts
Group memberships: Members
Show profile · Link to this post
I tried to change the ip into the server name and it fails too:

SEND XML: <stream:stream to='sepbx' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
RECV XML: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="sepbx" version="1.0" xml:lang="en" id="c03c0085" >
RECV XML: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" /><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth" /><register xmlns="http://jabber.org/features/iq-register" /></stream:features>
SEND XML: <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
RECV XML: <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
SEND XML: <stream:stream to='sepbx' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
RECV XML: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="sepbx" version="1.0" xml:lang="en" id="c03c0085" >
RECV XML: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth" /><register xmlns="http://jabber.org/features/iq-register" /></stream:features>
SEND XML: <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">AAA=</auth>
SEND XML: </stream:stream>
SEND XML: <stream:stream to='sepbx' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>



is there a write up on translating these debug?
This post was edited on 2013-03-06, 19:16 by Alex.
Avatar
Koterpillar #9
Member since May 2007 · 32 posts · Location: Russia
Group memberships: Members
Show profile · Link to this post
You yourself are sending the end of stream. Maybe because xmpp gets garbage collected? And where in the log the 5 sec delay is?
nebohodimo IM developer
Avatar
Jabberer #10
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
As Koterpillar said it would be helpful to know where the 5000ms delay are.

Did you change the content of the auth tag (AAA=)? Because the current data is invalid when decoded.

The server sends never a response to you auth (valid or invalid). Which server software are you using?
Software Developer
AG-Software
Avatar
Jabberer #11
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
I think its much easier to get started with the examples that ship with the SDK.
Software Developer
AG-Software
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