Let’s say that you met a Muslim brother and greeted him with the Salams and both of you were walking,so the Sunnah is that if an electric pole or a tree comes in between both of you, then you greet each other with the Salams again.
Abu Hurairah (May Allah be pleased with him) reported:
[Abu Dawud].
And it was narrated from Al-Bara bin Azib (رضي الله عنه) that the Messenger of Allah ﷺ said: “No two Muslims greet each other and shake hands with each other and praise Allah, but they seperate with all their sins forgiven.”
[Part of a Hadith from Musnad Imam Ahmad, Silsilatul Ahadith As-Saheehah of Shaikh Al-Albani 2741]
[T.N: The second Hadith above was translated by Abu Muaaz Mohammed Manna, please inform if you get a better translation or for any discrepancies.]