With types (independently of which language) you could encode the knowledge of the sequence you mention. For ex. send_message could take an AuthenticatedClient type. This way, instead of having it all in your head as implicit, it is explicitly described, and in many cases, impossible to use wrong.