Update message loops sample to detect all duplicate messages then stop connection when new message is not duplicate instead of running forever

Currently message loops sample detect duplicate messages, but still continue run forever, in this case it could cause some difficult to look browser console logging and server trace log files too.

This change will update message loops sample to detect all duplicate messages then stop the connection when new message is not duplicate instead of running forever, so it will be easy to investigate on client and server.
If you still stop the connection here, you could make this an else if.