TODO refactor sessions, unify tcp and udp endpoints