I think you handled it pretty well, if someone is behaving childishly then they need that boundary. And you repaired it afterwards by expressing warmth and concern for him. Understanding why he's behaving badly doesn't mean you let him get away with it. If you'd expressed yourself in an angry or defensive way then that wouldn't have been helpful, but it sounded like you were assertive and calm about it. What is wrong with being calm and direct when calling out bad behaviour? Is it too unnatural for you?