now sending message when user leaves the game
This commit is contained in:
parent
5a08e30df1
commit
d67904fe34
@ -5,3 +5,4 @@ export const channel_on_game_update = "on_game_update"
|
||||
export const channel_leave_game = "leave_game"
|
||||
export const channel_on_game_end = "on_game_end"
|
||||
export const channel_on_game_crashed = "on_game_crashed"
|
||||
export const channel_on_game_user_leave = "on_game_user_leave"
|
||||
@ -5,7 +5,7 @@ import { RTMTWS } from "./rtmt/rtmt_websocket";
|
||||
import cors from "cors"
|
||||
import { generateKey } from "./key_factory";
|
||||
import { MatchMaker } from "./matcmaker";
|
||||
import { channel_game_move, channel_leave_game, channel_new_game, channel_on_game_crashed, channel_on_game_start, channel_on_game_update } from "./channel_names";
|
||||
import { channel_game_move, channel_leave_game, channel_new_game, channel_on_game_crashed, channel_on_game_start, channel_on_game_update, channel_on_game_user_leave } from "./channel_names";
|
||||
import { Bytes } from "./rtmt/rtmt";
|
||||
import { createGame, Game, GameMove } from "./mancala";
|
||||
|
||||
@ -87,9 +87,9 @@ rtmt.listenMessage(channel_leave_game, (userKey: string, message: Bytes) => {
|
||||
const game = gameStore.get(userKey)
|
||||
if (game) {
|
||||
deleteGame(game)
|
||||
const data = encodeText(JSON.stringify(game))
|
||||
rtmt.sendMessage(game.player1, channel_on_game_update, data)
|
||||
rtmt.sendMessage(game.player2, channel_on_game_update, data)
|
||||
const data = encodeText(userKey)
|
||||
rtmt.sendMessage(game.player1, channel_on_game_user_leave, data)
|
||||
rtmt.sendMessage(game.player2, channel_on_game_user_leave, data)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -14,7 +14,6 @@ export class Game {
|
||||
}
|
||||
|
||||
public moveByIndex(holeIndex: number, player: "player1" | "player2") {
|
||||
throw new Error("afdad")
|
||||
let hole = this.board.player1Holes[holeIndex]
|
||||
|
||||
if (player == "player2") {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user