What is Megaphone?

What is Megaphone?
The Megaphone project is about enhancing open source chat software. Specifically, the goal is to allow ejabberd to support 1,000,000 simultaneous users. See The Plan page for more details on how I plan to solve this problem. See the About this Blog page for more details on why I created this blog.

Sunday, January 1, 2012

The ejabberd_socket Hand-Off


Previously...
  • I fixed an issue with HTTP headers
  • Things did not work: I resolved to go to a more basic level
  • I identified several alternatives to pursue
Megaphone will need to define a module that uses the listener pattern/interface that ejabberd defines.  To use this pattern, you first have to add some setup to the ejabberd.cfg file.  That file has a section of the following form:


{listen,
 [ <listen spec>, ... ]
}


Where <listen spec> has the form:


{ <port number>, <module>, [<module options>] }


For example, here is the bit for the regular port 5222 listener:

{5222, ejabberd_c2s, [
{certfile, "/opt/ejabberd-2.1.9/conf/server.pem"}, starttls,
{access, c2s},
{shaper, c2s_shaper},
{max_stanza_size, 65536}
]},

In that example, the port is 5222, the erlang module is ejabberd_c2s, and the options are the rest.

To complete the pattern, the module referenced by ejabberd.cfg needs to define a function that has the form:

start (SocketData, Options) 


Where SocketData is a tuple of the form


{ <socket module>, <socket> }


And Options is the list from ejabberd.cfg.


From testing this a little, it looks like <socket module> is "gen_tcp" and <socket> is the local TCP port number.


Megaphone needs to define a line in the file like this:


{ 6280, megaphone, [] }


And to define a function like:


start ( {gen_tcp, Socket}, _Options ) ->

No comments:

Post a Comment