implement room join and leave function.