😕what do I do?

My boyfriend of two years and I are going through something a little tough. About a year ago, he was communicating with his ex and flirting with her in a sexual way and just talking to her anyways. I just found out about this today, and I’m having difficulty dealing with it and I’m confused on how to act. I don’t want to break up I’m just very hurt because I never expected it from him. I was told to give him some space, but we practically live together. What would you do?? How would you feel? Help!