There is essentially a giant "order sheet" and orders get filled in a specific way by market makers. The way they are filled depends on what type of order you've put in and what the bid/ask spread is.
if the bid price is $10, thats what you can sell the shares for
if the ask price is $10.15, thats what you can buy shares at.
Your order would never get filled at $50 if the price is $10, it would get filled at around $10.15 because thats what the ask price is.
Yes, its certainly real-time and reflects the latest trades but the latest trades are based off of the bid/ask which keeps things pretty efficient.