refactor : use constant for channel names
This commit is contained in:
parent
031e2b1af1
commit
3eed2e96df
@ -6,6 +6,8 @@ import { RTMTWS } from "./rtmt/rtmt_websocket";
|
|||||||
import {
|
import {
|
||||||
channel_game_move,
|
channel_game_move,
|
||||||
channel_leave_game,
|
channel_leave_game,
|
||||||
|
channel_on_game_crashed,
|
||||||
|
channel_on_game_start,
|
||||||
channel_on_game_update,
|
channel_on_game_update,
|
||||||
channel_on_game_user_leave,
|
channel_on_game_user_leave,
|
||||||
} from "./channel_names";
|
} from "./channel_names";
|
||||||
@ -69,7 +71,7 @@ const Home: FunctionComponent<{ initial?: number }> = ({ initial = 0 }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const listenMessages = (pitAnimator: PitAnimator) => {
|
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 newGame: CommonMancalaGame = message as CommonMancalaGame;
|
||||||
const mancalaGame = MancalaGame.createFromMancalaGame(newGame);
|
const mancalaGame = MancalaGame.createFromMancalaGame(newGame);
|
||||||
setSearchingOpponent(false);
|
setSearchingOpponent(false);
|
||||||
@ -84,7 +86,7 @@ const Home: FunctionComponent<{ initial?: number }> = ({ initial = 0 }) => {
|
|||||||
pitAnimator.setUpdatedGame(mancalaGame);
|
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;
|
const newCrashMessage = message as string;
|
||||||
console.error("on_game_crash");
|
console.error("on_game_crash");
|
||||||
console.error(newCrashMessage);
|
console.error(newCrashMessage);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user