[JDEV] (HELP!) How to get a JabberSession pointer from JabberCOM

Michael F Lin Michael_F_Lin at us.ibm.com
Fri Feb 23 06:32:43 CST 2001


Jim,

The crash is most likely because of an unhandled exception. The
#import-generated COM wrappers you are using throw a _com_error exception
whenever a COM method fails (i.e. FAILED(hr)). Therefore it is advisable to
wrap any calls like so,

try
{
// your code here...
}
catch( _com_error& e )
{
// do something with e
}

This might help solve your problem. Also, I am not sure that you are
passing the strings correctly. Try doing (for example):

pSession->PutServer( _bstr_t( "vista.internal" ) );

The _bstr_t compiler support class will handle conversions to UNICODE and
the system BSTR strings. Note that _bstr_t will also throw _com_error
exceptions on failures, but in practice this never really happens.

Another possibility is that you should not call PutStatus until after you
are connected. It is only used for setting your availability once you are
connected to the server. Although I am looking at the JabberCOM source and
it should not cause the exception even if you call PutStatus before you are
connected.

-Mike

dai_jin at 21cn.com@jabber.org on 02/23/2001 02:46:12 AM

Please respond to jdev at jabber.org

Sent by:  jdev-admin at jabber.org


To:   jdev at jabber.org
cc:
Subject:  Re: Re: Re: [JDEV] (HELP!) How to get a JabberSession pointer
      from JabberCOM



Hi Mike,

    I have solved the problem on your help. Thank you very much. But
another problem appeared. I use these
code to connect the server:

pSession->PutServer(L"vista.internal");
pSession->PutUsername(L"dddd");
pSession->PutPassword(L"dddd");
pSession->PutResource(L"dddd");
pSession->PutPort(5222);
pSession->PutStatus(L"Working");
pSession->DoConnect(false, JabberAuthType(5));

But it return a Runtime error: abnormal program termination

I think i should missed something, right?

Any help would be greatly appreciated. Thanks!
Jim


>
> Jim,
>
> Make sure you are calling CoInitialize( NULL ) in the thread. If this
does
> not help you must examine the HRESULT returned to determine what the
> problem is. You can use the compiler support class _com_error to extract
an
> error description as a string. Read more about this in the MSDN
> documentation.
>
> -Mike
>
> dai_jin at 21cn.com@jabber.org on 02/22/2001 04:46:00 AM
>
> Please respond to jdev at jabber.org
>
> Sent by:  jdev-admin at jabber.org
>
>
> To:   jdev at jabber.org
> cc:
> Subject:  Re: Re: [JDEV] (HELP!) How to get a JabberSession pointer from
>       JabberCOM
>
>
>
> Hi Mike,
>
>     Thanks for your help.
>     I tried to change the __uuidof(IJabberSession) to
> __uuidof(JabberSession), but i still got error. Indeed, i tried using
> CLSID(f6c7a239-b7b1-11d3-aecb-00a076a018e8). I still can't get the
pointer.
> Can anyone help me?
>
> Thanks very much.
> Jim
>
> >
> > Hi Jim,
> >
> > The problem here is in __uuidof(IJabberSession). This gives you the
GUID
> of
> > the IJabberSession interface. However, what you want to pass to
> > CreateInstance is the GUID of a class, not of an interface. I'm not
> exactly
> > sure how #import would have decided to declare the JabberSession class,
> but
> > you might try __uuidof(JabberSession) or CLSID_JabberSession.
> >
> > Hope this helps,
> > Mike Lin
> > mflin at us.ibm.com
> >
> > dai_jin at 21cn.com@jabber.org on 02/21/2001 08:35:38 AM
> >
> > Please respond to jdev at jabber.org
> >
> > Sent by:  jdev-admin at jabber.org
> >
> >
> > To:   jdev at jabber.org
> > cc:
> > Subject:  [JDEV] (HELP!) How to get a JabberSession pointer from
> JabberCOM
> >
> >
> >
> > I imported JabberCOM and used following code:
> >
> > IJabberSessionPtr pSession;
> > HRESULT hr;
> > hr = pMsg.CreateInstance(__uuidof(IJabberSession));
> > if (SUCCEEDED(hr))
> > {...}
> >
> > but i always get an error(SUCCEEDED(hr) is FALSE).
> > What i missed?
> >
> > thanks.
> > Jim
> > ----------------------------------------------
> > »¶Ó­Ê¹Óà 21CN µç×ÓÓʼþϵͳ http://www.21cn.com
> > Thank you for using 21cn.com Email system
> >
> >
> > _______________________________________________
> > jdev mailing list
> > jdev at jabber.org
> > http://mailman.jabber.org/listinfo/jdev
> >
> >
> >
> >
> > _______________________________________________
> > jdev mailing list
> > jdev at jabber.org
> > http://mailman.jabber.org/listinfo/jdev
> ----------------------------------------------
> »¶Ó­Ê¹Óà 21CN µç×ÓÓʼþϵͳ http://www.21cn.com
> Thank you for using 21cn.com Email system
>
>
> _______________________________________________
> jdev mailing list
> jdev at jabber.org
> http://mailman.jabber.org/listinfo/jdev
>
>
>
>
> _______________________________________________
> jdev mailing list
> jdev at jabber.org
> http://mailman.jabber.org/listinfo/jdev
----------------------------------------------
»¶Ó­Ê¹Óà 21CN µç×ÓÓʼþϵͳ http://www.21cn.com
Thank you for using 21cn.com Email system


_______________________________________________
jdev mailing list
jdev at jabber.org
http://mailman.jabber.org/listinfo/jdev







More information about the JDev mailing list