Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Page:  1  2  next
Avatar
alinux #1
Member since Feb 2008 · 20 posts
Group memberships: Members
Show profile · Link to this post
Subject: Converting Example to VC++
Hey All

I am trying to convert the sample C# to VC++

// test23.cpp : main project file.

#include "stdafx.h"
using namespace agsXMPP;
using namespace agsXMPP::Xml;
using namespace agsXMPP::Xml::Dom;
using namespace agsXMPP::protocol;
using namespace agsXMPP::protocol::iq;
using namespace agsXMPP::protocol::iq::auth;
using namespace agsXMPP::protocol::iq::agent;
using namespace agsXMPP::protocol::client;

using namespace System;
using namespace System::Collections::Generic;
using namespace System::Text;
int main(array<System::String ^> ^args)
{
  
XmppClientConnection ^ xmpp =  gcnew XmppClientConnection("jabber.org");
xmpp->Open("myusername", "mysecret");
Message ^ sms = gcnew Message;
//xmpp->Send(gcnew Message("test@jabber.org",  MessageType->chat, "Hello, how are you?"));
xmpp->OnLogin += delegate(System::Object ^) { xmpp->Send(new Message("test@jabber.org", MessageType.chat, "Hello, how are you?")); };
return 0;
}


That is what I achieved so far however ..the line below seems to be giving out errors no matter what.

xmpp->OnLogin += delegate(System::Object ^) { xmpp->Send(new Message("test@jabber.org", MessageType.chat, "Hello, how are you?")); };
Avatar
Alex #2
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Attached is a small VC++ example which works for us.

Alex
Alexander Gnauck
AG-Software
The author has attached one file to this post:
SendMessageCPP.zip 5 kBytes
You have no permission to open this file.
Avatar
alinux #3
Member since Feb 2008 · 20 posts
Group memberships: Members
Show profile · Link to this post
Thanks for the reply, actually  I got it to work using your example...however I still wonder how I am going to make the onLogin event handler work, if I use Visual Studio .net instead of Visual Studio 2005 Pro would it make any difference ?


Thx
Avatar
alinux #4
Member since Feb 2008 · 20 posts
Group memberships: Members
Show profile · Link to this post
Seems to me as if

msg->To = gcnew Jid("9613632799@ahwar.net");

In the sample code is not functioning correctly, I have tried several of my servers and I only keep getting host not found and 404 errors. Using Wireshark I could not see the To JID in the stream.
Avatar
Alex #5
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Then there is a problem on your XMPP server, or the XMPP you send to is not on the federated network.
Alexander Gnauck
AG-Software
Avatar
Alex #6
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #3
Quote by alinux:
Thanks for the reply, actually  I got it to work using your example...however I still wonder how I am going to make the onLogin event handler work, if I use Visual Studio .net instead of Visual Studio 2005 Pro would it make any difference ?
I don't think the Visual Studio version matters, it works also with the free express version.
The agsXMPP event handlers work like all other .NET event handlers. You should find the answer in the MSDN. However its more difficult in a console project, so you should start with a windows forms project or use classes in your console project.

Alex
Alexander Gnauck
AG-Software
Avatar
alinux #7
Member since Feb 2008 · 20 posts
Group memberships: Members
Show profile · Link to this post
Fair enough..I appreciate your help Alex.

Can you shed any light on why the messages are not arriving at the receivers end I used


Code 404 host-unknown is the reply I get from the XMPP server

#include "stdafx.h"

using namespace System;
using namespace System::Threading;

using namespace agsXMPP;
using namespace agsXMPP::protocol::client;


int main(array<System::String ^> ^args)
{       
    XmppClientConnection ^ xmpp = gcnew  XmppClientConnection();
    xmpp->Username = "9613041705@myserver.net";    // Add your username here
    xmpp->Password = "6546546465";
    xmpp->Server = "xx.xx.xx.xx";
    xmpp->Port = 8080;
   

    xmpp->Open();

    Message ^ msg = gcnew Message;
    msg->To = gcnew Jid("9613632799@myserver.net");    // The receiver of the Message
//msg->To = gcnew Jid("9613041705");
    msg->Body = "Test Message";

    Threading::Thread::Sleep(5000);

    xmpp->Send(msg);

    Threading::Thread::Sleep(5000);

    return 0;
}
Avatar
Alex #8
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
your username is wrong.
Your username is in the format user@server which is a jid. The server part is the string in front of the @.
Which server are you using for your tests?

Alex
Alexander Gnauck
AG-Software
Avatar
Alex #9
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
and server is not a quatted IP and must be the domain part of your JabberId
Alexander Gnauck
AG-Software
Avatar
alinux #10
Member since Feb 2008 · 20 posts
Group memberships: Members
Show profile · Link to this post
When Using the domain name "The example below is as Is"

int main(array<System::String ^> ^args)
{       
    XmppClientConnection ^ xmpp = gcnew  XmppClientConnection();
    xmpp->Username = "9613041705@ahwar.net";    // Add your username here
    xmpp->Password = "xxxxxx";
    xmpp->Server = "ahwar.net";
    xmpp->Port = 443;
   

    xmpp->Open();

    Message ^ msg = gcnew Message;
    msg->To = gcnew Jid("9613632799@ahwar.net");    // The receiver of the Message
//msg->To = gcnew Jid("9613041705");
    msg->Body = "Test Message";

    Threading::Thread::Sleep(5000);

    xmpp->Send(msg);

    Threading::Thread::Sleep(5000);

    return 0;
}

I cant see any traffic leaving for the server..should this client check for the xmpp-client srv ? Or does it simply resolve ahwar.net ?
The servers port is 443 as set...and it is talking the server correctly on that port
xmpp->Server = "ahwar.net"; does not work because it points to the wrong address
xmpp->Server = "xmpp.ahwar.net"; works because it works to the correct address as said above we use srv to point to the server through the domain.

Can u see anything wrong in the settings above ?

Thx
Avatar
Alex #11
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
If you set
  1. xmpp->AutoResolveConnectServer = true;
than its resolving the xmpp server automatically from the SRV records if they are set (which is the case for your server).

Your username property is still wrong.

You don't have to set the Port if you use AutoResolveConnectServer.

Alex
Alexander Gnauck
AG-Software
Avatar
alinux #12
Member since Feb 2008 · 20 posts
Group memberships: Members
Show profile · Link to this post
Thank you for your help so far I edited the config file to use

xmpp->AutoResolveConnectServer = true;

and I fixed my username

when I watch the traffic in Wireshark now I can see that the simple client logs on and it retrieves the contact list and it sends the message "Test Message" to the receiver in question

Any reasons why it would not arrive at the receiver account ?
Avatar
Alex #13
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by alinux:
Any reasons why it would not arrive at the receiver account ?

there could be many reasons, this could also be a server issue.
  • Some servers eg. only route messages if the contacts have mutual subscription
  • Some servers allow you only to send messages if you mark yourself on available (xmpp->SendMyPresence())
  • Some servers route messages only if the receiver is online.
  • .....

Alex
Alexander Gnauck
AG-Software
Avatar
alinux #14
Member since Feb 2008 · 20 posts
Group memberships: Members
Show profile · Link to this post
hmm..

    * Some servers eg. only route messages if the contacts have mutual subscription
       The sender is on the contact list of the receiver

    * Some servers allow you only to send messages if you mark yourself on available (xmpp->SendMyPresence())
     
    * Some servers route messages only if the receiver is online.

As for the two points above, I am logged in with the receiver account on my computer and executing from the same computer I have added the code for xmpp->SendMyPresence() before sending the message the chat window displayed the following

9613632799 has logged back in.
9613632799 has logged out.

I.e. I was online at the time of sending, could it be something else. Unicode etc ?
Avatar
Alex #15
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I have modified my example a bit. Please look at the new example. This should work in all cases.

Alex
Alexander Gnauck
AG-Software
The author has attached one file to this post:
SendMessageCPP.zip 5.1 kBytes
You have no permission to open this file.
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:
Page:  1  2  next
Forum: agsXMPP SDK Support RSS