Re: Component services, custom requests handling
From: Petr Mensik <pihhan@xxxxxxxxx>
Date: Tue, 02 Jan 2007 02:30:41 +0100
Jakob Schroeter napsal(a):
> Hi,
> 
> On Monday January 1 2007 13:57, Petr Mensik wrote:
>> Hello,
>>
>> i am trying to write some component robot with some bot features. I
>> would like to implement some disco browsing of available functions,
>> contacts, and maybe some generic listing.
>>
>> Problem is, i found most handlers are more to handle requests to other
>> entities, such as server or contacts from roster. There is disco()
>> class, which i can setup with identity, version things. But i did not
>> found something, where can i add new items.
> 
> You can use DiscoNodeHandler and Disco::registerNodeHandler() for this.
I discovered some time after asking, that it is possible to write
DiscoNodeHandler, which can do some very basic browsing capability.
Problem is, i found root node most problematic. Like in other handlers,
there is not default handler in case packet did not match. There is also
no option to specify empty node, so i can register to main node and make
starting point for browsing. From what i saw from gloox 0.8, it tries
every node handler when node part is empty. It runs every handler
registered, but always return to the same list. It does not do any
concatenation of results. It is not known which value will be returned,
as order of items in map is not same as order of inserting, AFAIK. I
failed with browsing bot. It behaved very strange, but it worked with
node specified in Psi. Unfortunately, many clients does not allow
specifying node item before browsing disco items, so it might be
impossible making some items in browser. I think there should me option
to set root element handler. Maybe with empty node registered, but it
needs change from executing every handler to executing special handler
on empty node.

Also, in case component is used, it is not possible add jid into
browsing, or different resources for main component jid. Node is only
part i can work with. It is fact it is not important often, and for
Client does not have a sense.
> 
> 
>> Also, i would like output be 
>> different based on jid, so admin can see more than user. I know i can
>> disable disco features of Client and Component. But i dont know where
>> can i put my own handlers in case request are arriving to me, not
>> responses from what i asked.
> 
> Unfortunately, this is not possible with the current DiscoNodeHandler. There 
> is no way to know who sent a disco request. I guess this needs fixing.
> 
> 
>> Is there some another API, or is it done with normal IqHandler? How can
>> i register my class to receive request from other entities, so i can
>> write custom disco browsing? Can i register for example generic
>> IqHandler, which will handle all packets not handled by ClientBase
>> registered IqHandlers? So i can generate custom error responses, or log
>> it somehow special (to see what users expect etc.).
> 
> It's perfectly possible to use IqHandlers to (re)implement this. (Disco is 
> just an IqHandler, too.)
Yes, it can be done. I made some basic disco class, similar to internal
Disco. It works well. But i am little missing fallback handler, where
can i generate IqHandler for every namespace not registered with main
class. I could log unknown namespace for example, so i can see what
should i implement next. Or what attack was used on me. I could have
several contacts in my component for example, and have different
handlers for each of them. So i could have one handler, which compares
username part of jid, and forward to special class. Or i might want
generate custom error not implemented, for example in more languages or
so. I know it saves me from generating unsupported response for every
not supported namespace, but i miss i can override it somehow. This part
i cannot reimplement without changing library itself.
> 
> cheers,
> Jakob
> 


-- 
Petr Menšík
Radní Sdružení Tišnet


Attachment: signature.asc
Description: OpenPGP digital signature

-- 
gloox-dev mailing list
to unsubscribe:
send a message with subject 'unsubscribe gloox-dev' to minimalist@xxxxxxxxxx