When your child is frustrated, it's much better to come along side her, rather than take that moment to teach her a lesson because she is not going to learn it in that moment. A frustrated child doesn't have access to that left, logical, linear brain, that part of the brain that would process whatever wise teaching you had at the moment.
When they are frustrated, you want to come along side them. I use this analogy; I come along side them is like that, coming at them is where you are forcing them, this is where you have the push. You want to come along side her; so she when calms, she becomes receptive. That looks like, you would say things like, "Sweetheart, I get it. You were really hoping that she could come over and play. I understand. It's really a drag that she changed her mind. I want to hear about it, tell me."
You make comments that gets them in the way that they are nodding their head, and they are saying, "Yes." I call it "act one parenting" in my book. I talk a lot about it. It's a cornerstone of my work. Act one parenting is where you are helping the child settle down, be open to your parenthood and guidance. Most of the parents that I've worked with, use act two parenting; which is appealing to the left part of their brain, giving them reasons that they shouldn't be upset, trying to talk them out of their feelings, and it inflames the situation.
It's best when a child is frustrated; come along side them, let them settle down, and then you can provide the teaching moment that needs to happen.