Luong --
You might benefit by thinking of Firebase Realtime Database as a shared "notepad" for information (one that can be watched and an event triggered whenever the watched "thing" changes).
You could structure your database so that you have information about users (keep ID, win/loss, games currrently involved in,..), games (players in game, current position, current user to play, ...). You might have your clients, during a game, ensuring that only the player "to play" can make a move, and having the other "waiting" player watch for change (and noting when it is their move). If you are playing real-time and whenever each user logs in .. handline GoMoku/Caro play across timezines) this should work.
Make sense?