bassosimone/libight — pull request #17 by bassosimone (2014-08-19 16:23:47+00:00)
Title: Rework connection api

This pull request reworks the API of `IghtConnection` as follows:

1. Now events are processed by "slot" functions, rather than by virtual methods of the `IghtProtocol` class.

2. Now the data that was read is passed as a parameter to the read handler, while before the read handler needed to query such data explicitly.

3. There are now two constructors (one to attach to a socket and one to defer a connect), which replace the factory methods having the same semantic.

4. The error handler receives an instance of the `IghtError` class.

5. The buffered read/write code was removed from `IghtConnection`. I will reuse most of this code to implement a buffer class (based on `evbuffer`) in another pull request (I already have a prototype diff). The buffering code was added to `IghtConnection` because it made sense to do so in libneubot, which was to be written part in C/C++ and part in Java. Given that libight is to be written all in C++11, there was no reason to keep the buffering code in the class that manages connections.

While there, the echo client test code was moved in `test/net`, to make the tree more tidy. Another echo client code, instead, was removed because no longer relevant.

It goes without saying that this pull request does not conclude the work on `IghtConnection`, but at least now the API should be close to the one on which @hellais and I agreed. In particular, more work is to be done on the implementation of `IghtConnection` (RAII, e.g., can be done after #14 is accepted).