Good question.
This is a thing that many people find very difficult to accept.
We see it as an affectionate and friendly gesture that our dog rushes up to us when we come in.
What is actually happening is ritualised greeting and is exactly the same as the greeting seen in wolf packs. All memebers of the pack greet each other depending on rank. The Alpha, or leader, will stand quite still and turn his head away from such greetings by his subordinates, avoiding eye contact and totally ignoring the fuss. This asserts dominance and reinforces the subordinate position of the greeter. He will acknoweldge lower ranking idividuals only on his terms in his own time when they are behaving in a calm and respectful way.

So the easiest thing in the world for your dog to understand is for you to advertise the fact that you are the leader of the pack by acting in the same way.
Whenever you come into the room your dog is in pretend that it is not there, what ever it does to gain attention. It is not looking for you to be affectionate towards it- it wants acknowledgment of it's high rank in the pack.
Eventually the dog will accept that you are not going to acknowledge it and it will go to lie down and have a think (often it will be thinking of another way to get your attention!). It may come back two or three times to try again before giving up. If you wait until the dog has been lying away from you for at least ten minutes (time this on a clock) then call the dog over to you the dog will be just as happy to see you but will understand the very strong message you have been displaying.
This can be very hard to do for a lot of people as we are programmed to empathise with our dogs feelings as though the dog is human. Once you see it working though it is clear that the dog really does respect the message you give it.

Give it a try the next time you visit a freind with a dog - ignore their dog until it stops asking for attention, lies down away from you for ten minutes and then call it over. You will see the attitude of the dog change towards you.