mercoledì, 23 aprile 2008
In Erlang we can use many method to access to lists and tuples, and some of them are very quick and easy.
With ++ and -- operators you can add and subtract lists, like in the following example:
Thelist=[1,2,3,4,5,6,7,8,9,10],
Even = lists:filter(fun(E) ->
E rem 2 == 0
end,
Thelist),
Odd=Thelist -- Even,
Newlist = Odd ++ [ one, five ].
So Odd list will contains [1,3,5,7,9], Even list will contains [2,4,6,8,10] and Newlist will contain [1,3,5,7,9,one,five].
lunedì, 07 aprile 2008
I've recently been involved in the problem of Flash (7.0 and following) XML socket.
Flash uses a "strange" kind of packet transfer in XML socket so Ejabberd 2.0.0 is not compatible with some Flash version.
I've seen a patch for Ejabberd 1.1.X versions and I've adapted it to fit with ejabberd 2.0.0.
Please note that this patch changes configure.ac file, but you must DO NOT run aclocal command.
At the moment
aclocal.m4 file contains some macro that
aclocal command will overwrite!
So please follow these steps to apply this patch to Ejabberd 2.0.0:
patch -p0 <flash-xml-ejabberd-2.0.0.diff
rm configure
autoconf
./configure --enable-flash-hack
make
And you'll be able to use XMPP like this:
<?xml version='1.0'?>
<flash:stream to='example.net' xmlns='jabber:client'
xmlns:flash='http://www.jabber.com/streams/flash' version='1.0'>
</flash:stream>
The patch is available here.
lunedì, 07 aprile 2008
As promised I'm releasing the cookie patch for ejabberd 2.0. The patch is quite simple and takes few minutes to check it out.
To apply the patch cumulatively, simply do the following
ejabberd/src/web/ $ patch < $HOME/ejabberd-2.0-cookie.patch
Otherwise you could apply the patch to single files:
ejabberd/src/web/ $ patch ejabberd_http.hrl $HOME/ejabberd_http_hrl.patch
ejabberd/src/web/ $ patch ejabberd_http.erl $HOME/ejabberd_http_erl.patch
Let me know if you got errors applying this patch.
Links:
ejabberd 2.0 Cumulative Cookie Patch
ejabberd_http Source Cookie Patch
ejabberd_http Header Cookie Patch
mercoledì, 26 marzo 2008
There's a very useful method to dynamically change verbosity level in ejabberd 2.0.0.
You must connect with a remote shell to the node you're interested to debug and simply write:
ejabberd_loglevel:set(LogLevel).
Where LogLevel is:
- 0: No ejabberd log at all (not recommended)
- 1: Critical
- 2: Error
- 3: Warning
- 4: Info
- 5: Debug
venerdì, 14 marzo 2008
If you need to quickly make a cluster for many ejabberd nodes, you can find that a module that quickly initialize Mnesia tables can be very useful.
Follows the code of this module, really simple and autoexplicative.
-module(set_cluster_tables).
-export([
setCopyTable/1
]).
loopTables(List, Dest, Node) ->
lists:foreach(fun(Table) ->
io:format("Change table copy for ~p in ~p\n",[Table,Dest]),
mnesia:add_table_copy(Table, Node, Dest)
end,List).
setCopyTable() ->
io:format("Adding schema table\n",[]),
mnesia:change_table_copy_type(schema, node(), disc_copies),
TablesInRAM=[session,s2s,route,acl],
TablesInDisc=[muc_registered,muc_room,motd,last_activity,roster,passwd,privacy
,offline_msg,disco_publish,vcard,private_storage,pubsub_node],
loopTables(TablesInRAM,ram_copies,node()),
loopTables(TablesInDisc,disc_only_copies,node()).
So calling set_cluster_tables:setCopyTable(). you will have all specified tables copied from "master" node. Remember to exit using q(). or init:stop() command, to cleanly exit from the shell.
mercoledì, 12 marzo 2008
In these days I'm using ejabberd 2.0.0, and I'm making a new module to set IM presences on Splinder site.
The
I've seen that the hook call
c2s_update_presence in
ejabberd_c2s module, is not using resource part of user's jid.
After a short discussion in the
ejabberd developer chatroom, and after a little talk with
badlop, we have decided to patch che
ejabberd_c2s code.
I think it may be useful to use resource too, so I've patched
session_established function, from:
PresenceEl = ejabberd_hooks:run_fold(
c2s_update_presence,
Server,
NewEl,
[User, Server]),
to:
PresenceEl = ejabberd_hooks:run_fold(
c2s_update_presence,
Server,
NewEl,
[User, Server, StateData#state.resource]),
So the code executing the hook can be independent from jid record but can use values inside this type of variable.
You can follow the story about this patch
here.