Regular Matrix is pretty straight-forward - you join rooms and send events. Events get propagated to all participating/federated servers that are in the room. You watch for incoming events.
The Matrix devs should be able to say more about their P2P implementation. :)