Abu Hurayra said, "Whoever meets his brother should greet him.
If a tree or wall comes between them and then he meets him, he should greet
him on the other side."
Mu'awiya ibn Qurra said, "My father told me, 'If you sit in a
gathering expecting good to come from, but then something occurs which
makes you leave, say, 'Peace be upon you,' and you will share in any good
that they obtain in that gathering. There are no people who sit in a gathering
and then split up without Allah having been mentioned, but that it is as
if they were leaving the corpse of a donkey.'"
Anas ibn Malik reported that the Companions of the Prophet, may
Allah bless him and grant him peace, used to gather and they would turn
towards the tree and a group of them would go to the right and a group
to its left. When they met again, they would greet one another.
Abu Hurayra reported that the Prophet, may Allah bless him and
grant him peace, said, "When a man comes to a gathering, he should give
the greeting. When he sits down and then thinks that he should leave before
the gathering has broken up, he should give the greeting. Neither is more
of a duty than the other."