uProxy/uproxy-networking — pull request #159 by trevj (2014-11-18 22:56:25+00:00)
Title: Refactoring of and unit tests for RtcToNet.Session life-cycle

So, we have a bunch of unit tests for `SocksToRtc.Session` "life-cycle" events, i.e. `onceReady` and `onceStopped`.

This pull request adds a similar set of tests for `RtcToNet.Session`. It also refactors `RtcToNet.Session` to be a little more like `SocksToRtc.Sesson`, chiefly to factor out a separate method, `receiveEndpointFromPeer_`, to deal with SOCKS session handshakes. I think this makes the code much more readable. For example, since there's no longer a single method which receives all data from the peerconnection we can avoid the long and tortuous switch statements exemplified by `handleWebRtcControlMessage_`. It should also be more amenable to testing, e.g. we can add unit tests just for `receiveEndpointFromPeer_`.

`SocksToRtc.Session`'s tests were implemented by this pull request:
https://github.com/uProxy/uproxy-networking/pull/141