The comments in the code explain how crossing connections are resolved.
This solution, unfortunately, does not account for the possibility of connection failures.
It can be that A has a severed connection to B, but A still thinks the connection is healthy. Now, B is aware that the connection has failed, and it tries to reconnect. The result is that A will respond with ConnectionRequestCrossed, and B will wait forever an incoming connection from A.