Matthias Wimmer wrote:
Hi Remy!
Remy HAREL schrieb am 2004-05-26 12:26:42:
Ok Mathias, but I don't understand how to use it. In fact, imagine I (
[EMAIL PROTECTED]) have a session opened... the current "sess" in c2s.c,
c2s_client_sx_callback. I 'm gonna send a packet to you ( [EMAIL PROTECTED] ),
juste before the sm_packet. the full jid of the session "sess" is mine,
[EMAIL PROTECTED] If I sent a message to you, I should be able to read somewhere
( in nad I suppose ) that this message is for "[EMAIL PROTECTED]", no ?
Sure you could ... but you realy SHOULD NOT do this. The task of c2s is
to authenticate you and to forward messages to your own session manager.
All processing of these messages should be done in the session manager
(sm) then.
Thanks Matthias, I know the role of the c2s, but since I'm writting a
distributed and high available jabberd2 server version, I have to know
for each jabber user I communicate with the # of the message sent (and
received so... ) to this guy. XML messages from c2s have more datas, to
be interpreted by something else ( like multiple routers ). This in
order to erase the SPOF we have due to a unique router.
How should I call nad_find_attr to do what I want ? I've tried
something like :
attr_tmp = nad_find_attr(nad,0,-1,"to",NULL); // here value is '-1'
recipient = (char*) malloc(sizeof(char) * NAD_AVAL_T(nad, attr_tmp);
recipient = (char*)NAD_AVAL(nad, attr_tmp); // crash, due to
attr_tmp's value
you have to tell nad_find_attr the handle of the element where you want
to search for the attribute ... there is nothing like a global search
for an attribute in a nad (AFAIK). So start with nad_find_elem ... you
get back a handle for the element which you can use in nad_find_attr.
Ok, Im' gonna try this....
Also don't forget the handling of namespaces!
oops, thanks
also your assignment won't work ... you only would produce a memory leak
... you are allocating memory and you throgh away the pointer to it in
the line afterwards ... your second assignment does not copy the string
in C but only assigns a pointer. You have to use something like the
following for the second line:
sprintf(recipient, "%.*s", NAD_AVAL_L(nad, attr_tmp), NAD_AVAL(nad, attr_tmp));
of course, you're right, snprintf... I used java so long that somme
reflexes are still here ! ;)
Another bug you have in your code is that you have to reserve memory for
the terminating zero byte in the string as well, not only for the pure
content of it.
-> yep, thx
due to attr_tmp which value's -1; nad_find_attr didn't find the
attribute "to". Moreover, this attribute value isn't "[EMAIL PROTECTED]" but
just "gabber"... so only the domain. I saw this by using tcpdump.
If you are searching for anything in XML you always have to check if you
got something back ... you can never expect all clients sending correct
XML streams.
Yes, don't worry, this is just a little part of my code...for exemple.
Tot kijk
Best regards i guess ?? ;)
so best regards matthias, and one more time thx
Matthias
--
Remy Harel - [EMAIL PROTECTED]
G.I.C.M - Distributed Systems & IT
Linux Registered User #224740
_______________________________________________
jdev mailing list
[EMAIL PROTECTED]
https://jabberstudio.org/mailman/listinfo/jdev