When playing video games, its often easy to forget that you're not the only person playing them. Some people when they switch to multiplayer either forget this fact or omit from their minds. Often we have grown so accustomed to playing against a computer that we treat our opponents without respect, a fact that has been evidenced by various online communities and the way they've been shown in various online media. If you are playing video games online whether it be a casual game of Minecraft or a competitive setting such as a fighting game, people deserve at least common courtesy rather than being hit with various insults and derogatory comments.
The most common situation of people being insulted or called various names is in shooters. Generally speaking, its a harsh place with teenagers and sometimes even children hurling vitriol. This is a classic example of respect not being given due to the anonymity of the internet and gamer names that comes with playing video games online. A person can choose to simply mute and ignore the offenders or simply find another game without these players in the session. These are one of the few groups of people that common courtesy that doesn't often affect so unless you can ignore these kinds of people, I would advise to simple avoid the problem.
When you end up playing a game and you end up winning against a singular opponent in a competitive setting, be it something as simple as a chess game or something as complicated as playing distance and footsies in a fighting game, your opponent deserves a compliment of some sorts after a match. Something as simple as a "GG" which stands for "Good game" or a simple thanks often takes the sting out of losing, which while a lot of people don't usually say so, are genuinely grateful for the compliments and will respond in kind. If someone ever compliments you on your game, its customary to thank them and offer a thanks in turn which will hopefully help foster a sense of friendship and future interaction between players.
Sometimes you'll end up with the person who will backhand your courtesy with insults and trashtalk but its not acceptable to sink to their level. Simply say your thanks for the match and move on, regardless if they continue to talk. If they end up sending you messages and continuing to bother you, be it private messaging or the online system messaging systems, block them and make sure to keep from responding. Oftentimes, people like this are only interested in persisting if the one they're tormenting continues to respond.
Overall, courtesy begets courtesy and rudeness begets rudeness. Its a simple rule of the world and should be carried over to the virtual one as well. The rules are not enforced but should at least be observed so that not everyone online will just be the worst of the online community. If you ever find yourself feel like you need to respond in kind to the insult, take a deep breath and push the person away with a simple button click. You are responsible for your own conduct in the end.