Re: Unhandled Exception in XMPP - WeOnlyDo Discussion board

Re: Unhandled Exception in XMPP (General questions)

by gothic_coder, Saturday, December 11, 2010, 10:26 (5097 days ago) @ gothic_coder

Also if i comment the statement which was causing the unhandled exception, It went on and ask for login and password, After that it ask for to whom i need to send the message and what, after providing the details it calls SendText but i get following error message


The value of ESP was not properly saved across a function call. This is usually a result of calling a function pointer declared with a different calling convention.

Here the whole code

[code]
//#import c:windowssystem32wodxmpp.dll no_namespace named_guids
#include wodxmpp.tlh

#include <atlbase.h>
CComModule _Module; // dummy required to utilize atlcom.h
#include <atlcom.h>

bool error = false;

// Define the wodXMMP events to be handled:

_ATL_FUNC_INFO OnConnectedInfo = {CC_STDCALL, VT_EMPTY, 0, VT_EMPTY};
_ATL_FUNC_INFO OnDisconnectedInfo = {CC_STDCALL, VT_EMPTY, 2, {VT_I4, VT_BSTR}};

class wodXMPPEvents : public IDispEventSimpleImpl<1, wodXMPPEvents, &DIID__IwodXMPPComEvents>
{
public:
wodXMPPEvents (IwodXMPPComPtr pwodXMPPCom)
{
m_pwodXMPPCom = pwodXMPPCom;
DispEventAdvise ( (IUnknown*)pwodXMPPCom);
}

virtual ~wodXMPPEvents ()
{
DispEventUnadvise ( (IUnknown*)m_pwodXMPPCom);
m_pwodXMPPCom.Release();
}

void __stdcall OnConnected ()
{
printf(
Connected, continuing....

);
}

void __stdcall OnDisconnected (long ErrorCode, BSTR ErrorText)
{
if (ErrorCode)
{
error = true;
_bstr_t err(ErrorText);
printf(
s
, (char *)err);
}
else
printf(
Done and disconnected
);
}

BEGIN_SINK_MAP (wodXMPPEvents)
SINK_ENTRY_INFO (1, DIID__IwodXMPPComEvents, 0, OnConnected, &OnConnectedInfo)
SINK_ENTRY_INFO (1, DIID__IwodXMPPComEvents, 1, OnDisconnected, &OnDisconnectedInfo)
END_SINK_MAP ()

private:
IwodXMPPComPtr m_pwodXMPPCom;
};

int main(int argc, char* argv[])
{
IwodXMPPComPtr pXMPP;
HRESULT hr = NULL;

CoInitialize (NULL);

hr = pXMPP.CreateInstance (CLSID_wodXMPPCom, NULL);
if (FAILED (hr))
{
_com_error comErr (hr);
printf ( Unable to load IwodXMPPCom interface.
Err # u: s , hr, comErr.ErrorMessage () );
CoUninitialize ();
return 99;
}

wodXMPPEvents *pEvents = new wodXMPPEvents(pXMPP);

//This was creating problem, Now i commented it.
//pXMPP->Blocking = VARIANT_FALSE;

//pXMPP->Register = VARIANT_TRUE; // register new account

VARIANT var;
var.vt = VT_ERROR;

char Login[256];
char Password[256];

printf( This sample will let you login to your Jabber account and send a message to one of your contacts.

);
printf( Enter your JID: );
scanf( s , Login);
printf( Enter your password: );
scanf( s , Password);

pXMPP->Login = _bstr_t(Login);
pXMPP->Password = _bstr_t(Password);

try
{
hr = pXMPP->Connect(var);
}
catch (_com_error e)
{
error = true;
}

if (!error)
{
char JID[256];
char message[1024];

printf( Send message to (JID): );
scanf( s , JID);
printf( Message: );
scanf(
[^
] ,message); //reads whole line from console

//pXMPP->Contacts->Add(_bstr_t( someone@wippien.com ))->Subscribe(); // you can add someone to your contact list...

//Now here it shows the error message.
pXMPP->SendText(_bstr_t(JID), _bstr_t(message));

pXMPP->Disconnect();
}
delete pEvents;
pXMPP.Release();
CoUninitialize ();

return 0;
}

[/code]

Looking forward for quick reply..


Thanks.


Complete thread: