SkewedAspect/precursors-server — pull request #22 by Morgul (2014-02-22 00:52:10+00:00)
Title: Communication Layer cleanup

This is a rather large change that will clean up the entire front-end of the server. The things to do are:

- [ ] Convert to Ranch
- [ ] Cleanup/rewrite `pre_client_connection`.
- [ ] Hook into the new auth system (Depends on #10.)
- [ ] Unitests

-----

## Design

The new communication layer is built much more inline with both the framework Ranch imposes, and the way things work on the client. Now our TCP and SSL communication is handled by Ranch, and for each connection, a new `pre_channesl_proto` pid is started. If it's an SSL connection, we create a new `pre_client_connection` pid. If it's TCP, we look up the TCP cookie in ETS and fid our `pre_client_connection` pid. Messages from either TCP or SSL are decoded in `pre_channels_proto`, and then send to the client pid as an `envelope` record. The client pid simply pattern matches against that record, and handled the messages as required. That's it.

This design removes a massive clusterfuck of code, and is much easier to intuit about, imho.

Questions, comments, angry rebuttals?