Relationship ended abruptly

So this a really long story and I don't know how to begin, but I'll try to be as concise as possible. 17 years ago I met a guy who I became close friends with. 3 years later he decided he wanted to date me, we were both in high school back then so it wasn't proper dating. Things were a bit weird for me as he was moving in circles and with people I did not approve of so I decided I'd cut all communication with him. Some years later he found me on Facebook and begged me to give him a chance to be in my life again, saying I was important to him, even though I didn't believe him at first I gave him a chance. We became even closer friends, with him calling me almost every day, a few times a day to talk about life for hours on end. I supported him with everything and he supported me too. Later on in the years I was going through a horrible time with my uncle dying unexpectedly and being dumped by a fiance, he was the only one who was there for me. And somehow we ended up dating yet again, this time it lasted for 4 years. I didn't plan to fall in love with him at all, I didn't plan what sort of relationship we would have and how things would or should turn out, but it happened and when it did, I realised I had never really loved anybody before. There were a lot of ups and downs during this time, but I thought that we were sorting things out in a good way and were on the same page. Until he randomly told me he'd started seeing someone else and wants to see how things will go with her. I am devasted and don't even know how or why this happened. So my question is how do I get over not being with him after having him in my life for all these years and him being the most important person to me.