refactor : use constant for channel names

This commit is contained in:
Halit Aksoy 2022-05-15 02:06:09 +03:00
parent 031e2b1af1
commit 3eed2e96df

View File

@ -6,6 +6,8 @@ import { RTMTWS } from "./rtmt/rtmt_websocket";
import {
channel_game_move,
channel_leave_game,
channel_on_game_crashed,
channel_on_game_start,
channel_on_game_update,
channel_on_game_user_leave,
} from "./channel_names";
@ -69,7 +71,7 @@ const Home: FunctionComponent<{ initial?: number }> = ({ initial = 0 }) => {
};
const listenMessages = (pitAnimator: PitAnimator) => {
context.rtmt.listenMessage("on_game_start", (message: Object) => {
context.rtmt.listenMessage(channel_on_game_start, (message: Object) => {
const newGame: CommonMancalaGame = message as CommonMancalaGame;
const mancalaGame = MancalaGame.createFromMancalaGame(newGame);
setSearchingOpponent(false);
@ -84,7 +86,7 @@ const Home: FunctionComponent<{ initial?: number }> = ({ initial = 0 }) => {
pitAnimator.setUpdatedGame(mancalaGame);
});
context.rtmt.listenMessage("on_game_crashed", (message: any) => {
context.rtmt.listenMessage(channel_on_game_crashed, (message: any) => {
const newCrashMessage = message as string;
console.error("on_game_crash");
console.error(newCrashMessage);