update for event emitter rtmt
This commit is contained in:
parent
23d2edb23e
commit
51d541b5e7
@ -23,18 +23,19 @@ const LobyPage: FunctionComponent<{
|
||||
|
||||
let navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
listenMessages();
|
||||
context.rtmt.sendMessage("new_game", {});
|
||||
}, []);
|
||||
|
||||
const listenMessages = () => {
|
||||
context.rtmt.listenMessage(channel_on_game_start, (message: Object) => {
|
||||
const newGame: CommonMancalaGame = message as CommonMancalaGame;
|
||||
navigate(`/game/${newGame.id}`)
|
||||
});
|
||||
const onGameStart = (message: Object) => {
|
||||
const newGame: CommonMancalaGame = message as CommonMancalaGame;
|
||||
navigate(`/game/${newGame.id}`)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
context.rtmt.addMessageListener(channel_on_game_start, onGameStart);
|
||||
context.rtmt.sendMessage("new_game", {});
|
||||
return () => {
|
||||
context.rtmt.removeMessageListener(channel_on_game_start, onGameStart);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const textColorOnAppBar = getColorByBrightness(
|
||||
context.themeManager.theme.appBarBgColor,
|
||||
context.themeManager.theme.textColor,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user