For a room chat, your Firebase database structure could be:-
Chat-DB
chat-Room
Room-Code
Message-List
Date-Stamp( as message ID)
Sender
Message-Text
You will need to save every message under the correct key.
When any user runs the app and enters the room code, you should read your Firebase and display the chat messages under that room before giving the user the ability to send his/her own message.