[ejabberd] Question related to pubsub avatars and HTTP access

Teemu Harju teemu.harju at gmail.com
Tue Jan 8 15:45:28 MSK 2008


Hi,

I've been experimenting with an idea about HTTP access to pubsub
nodes/items. First I have tried to get the user avatars, so that I can
display them on a web page. I just made a very simple module that fetches
one specific pubsub item from mnesia database containing the avatar data and
sends this over HTTP to a web browser. Now the problem is that this is
extremely slow. It takes around 30 seconds to get the image loaded. Its
96x96 15.9 kB png image. That shouldn't  take that long. Here is somewhat in
more detail what I do...

This is how I get the avatar data... I used Psi as a client to publish the
avatar image.

get_avatar_data(ItemId) ->
    F = fun() ->
                Q = qlc:q([Item#pubsub_item.payload || Item <-
mnesia:table(pubsub_item),

Item#pubsub_item.itemid == ItemId]),
                qlc:e(Q)
        end,
    {atomic, [[_, XMLData, _]]} = mnesia:transaction(F),
    jlib:decode_base64(xml:get_tag_cdata(XMLData)).


Then I use the ejabberd web server to send the data over HTTP like this...

process(LocalPath, _Request) ->
    case LocalPath of
        ["avatar"] ->
            Data = get_avatar_data(),
            {200, [{"Content-Type", "image/png"}], Data};
        _  ->
            ejabberd_web:error(not_found)
    end.

If I don't decode the base64 the page loads a lot faster, but naturally the
browser is not displaying the image. Any hints in what I'm doing wrong?

Also, I would be interested if anyone is thinking about similar efforts. I
mean accessing the pubsub data over HTTP and I don't need BOSH for this.

Regards,

Teemu

-- 
Teemu Harju

email/jabber: teemu.harju at gmail.com
blog: http://www.teemuharju.net

~~ "A computer is like air conditioning: it becomes useless when you open
windows." ~~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jabber.ru/pipermail/ejabberd/attachments/20080108/8dd7864e/attachment.htm 


More information about the ejabberd mailing list