Re: Re: Glooxd and disco
From: Anton Lauridsen <anton.lauridsen@xxxxxxxxx>
Date: Wed, 31 Mar 2010 17:26:45 +0200 (CEST)
On Wed, 2010-03-31 at 16:12 +0200, Jakob Schroeter wrote:

> Hi,
> 
> Quoting Anton Lauridsen <anton.lauridsen@xxxxxxxxx>:
> 
> > Hi
> >
> > I've pulled the latest version out of the trunk (r 111), The disco
> > implementation looks to be very much like a simple skeleton, I need a
> > better implementation than what I found, so I have started to implement
> > an improved version.
> 
> Yes, it's far from being complete.
> 
> 
> > For my purposes I want to use XEP-0030 to query the connecting client
> > (I'm working in parallel on an implementation of XEP-0009 Jabber-RPC)
> > for both the client and the server.
> >
> > I've implemented and registered a ServerEventHandler on the
> > ConfigManager, and want to query the connecting client in the
> > "handleClientConnected" call back. This works perfectly. In the
> > handleClientConnected method I create an IQ stanza. As I read and
> > understand XEP-0030 I MUST supply the session key in the id attribute of
> > the IQ stanza, unfortunately I cannot find any means of retrieving the
> > session key. it appears to me as if there is no way to retrieve the
> > session key related to a connected client and/or JID, Is there something
> > I have overlooked?
> 
> I'm not sure what you mean by 'session key'. The id attribute just  
> takes a unique id like the one generated by  
> gloox::ClientBase::getID(). You could keep a dummy instance of  
> ClientBase around for that or just copy the code. There's no way to  
> create an id in glooxd itself at this point.
> 
> cheers,
> Jakob
> 
> 
> plain text document attachment (footer.txt)
> 
> -- 
> gloox-dev mailing list
> to unsubscribe:
> send a message with subject 'unsubscribe gloox-dev' to minimalist@xxxxxxxxxx


I implemented a disco manager class, inheriting from
glooxd::DiscoManager, my DiscoManager has two methods:
QueryInfo and QueryItems, which creates an iq-query stanza. The code
looks like this:

in my implementation of handleClientConnected:

void XmppServer::handleClientConnected( const gloox::JID jid, const std::string 
localIP, int localPort, const std::string remoteIP, int remotePort )
{
    LOG4CPLUS_TRACE_METHOD(mLogger, "XmppServer::handleClientConnected");

    // Query the client for it's capabilities
    DiscoManager* disco = DiscoManager::instance();
    disco->QueryInfo(jid);
    disco->QueryItems(jid);
}


note the DiscoManager is my own implementation inheriting from
glooxd::DiscoManager. My QueryInfo looks like this:

void DiscoManager::QueryInfo(const gloox::JID& to)
{
    LOG4CPLUS_TRACE_METHOD(mLogger, "DiscoManager::QueryInfo");
    gloox::JID from("localhost");
    Info inf(gloox::IQ::Get, to, from);

    m_router.handleIncomingTag(inf.tag());
}

Info is a wrapper around the iq/query stanza with a query type of #info,
following a pattern similar to what gloox is using. As you can see, I do
not suppy an id to the constructor, since I have found no way of getting
this information. I believe it could potentially be retrieved from C2S,
using the JID to find the StreamBase from m_clients, unfortunately all
methods of accessing m_clients on C2S are marked "private".

>From my read of rfc-3920, combining section 4.4 (Stream Attributes) with
9.1.3 (id attribute of XML Stanzas) and 9.2.3 (IQ Semantics), I get the
impression that I should reuse the session key from the overall XML
stream when sending a get IQ stanza from the server to the connected
client, am I misreading the RFC, can I just supply any value in the id
attribute following the [RANDOM] recommendations of section 4.4?


/anton