Here's my two cents:
First, I am so sorry that you had to go through this. It's really hard when that happens. It probably feels like he chose her over you, or that you do not matter to him. I am truly sorry that it was your closest friend of all things.
I think, for one, you need to have a conversation with your boyfriend. You should sit him down and tell him that the relationship is on the table. It's important that you are clear and reasonable about your thoughts and needs. You should try to just get to the bottom of it. Was it just messing around, or does he have feelings for her? You should be clear also about how you feel and how he has hurt you. If it's a serious relationship, there are certain needs that need to be met.
I think one way to cope with this is to realize that you can love multiple people throughout your life. You may move on from him. You may meet someone else later. You never know. One thing to keep in mind is that love isn't just a once and done thing. You can end things with him and find someone else who will treat you better and remain loyal. You don't have to stay. Now, I know you probably love him. It's a really tough place to be. I think that you should plan out what a break up would look like. How would you handle it? You should be looking at a possible support system.
If you want to save the relationship, you need to talk about what happened. You need to make the rule that it should never happen again, or if you're cool with an open relationship, you should set some boundaries. I think that for one, asking him what you mean to him is important. Does he love you enough to stay loyal? Is he willing to change for you? Is he willing to meet you halfway and earn your trust back? If not, then I don't think he is the right one for you. Relationships aren't just about love: They involve respect and other virtues. It has to be maintainable. He needs to know that what he did was wrong.
At the end of the day, you have to ask yourself if it is worth it to stay, and if you want to heal this relationship. It'll take time to heal, but it will be all the better for it. If you can survive this, you can survive anything. I think one thing you need to work on right now is processing these emotions. Whether it be a close friend, a therapist, or your family. Just talk it out with someone. Share your feelings. That way, you'll at least have some experience with talking about the situation, so when you need to talk to your boyfriend, you can have an idea of what you want to say.
As for your close friend, she has shown a lack of respect for you. It may have been a lapse in judgement. Either way, you need to talk to her, or you could just drop her. You did not respect your relationship, nor she did not respect you.