fix join process
This commit is contained in:
parent
9236620b4c
commit
95637dc20b
|
|
@ -12,6 +12,7 @@ export const useWebsocketStore = defineStore("websocket", {
|
||||||
init(gameId) {
|
init(gameId) {
|
||||||
const player = usePlayerStore()
|
const player = usePlayerStore()
|
||||||
const game = useGameStore()
|
const game = useGameStore()
|
||||||
|
if (game.owner == player.id || game.opponent.id == player.id) window.location.href = window.location.origin + '/lobby/' + game.id
|
||||||
this.connection = new WebSocket(connectionUrl + "?gameId=" + gameId + "&playerId=" + player.id);
|
this.connection = new WebSocket(connectionUrl + "?gameId=" + gameId + "&playerId=" + player.id);
|
||||||
this.connection.onopen = function (event) {
|
this.connection.onopen = function (event) {
|
||||||
console.log(event);
|
console.log(event);
|
||||||
|
|
@ -46,7 +47,6 @@ export const useWebsocketStore = defineStore("websocket", {
|
||||||
break
|
break
|
||||||
case 'join':
|
case 'join':
|
||||||
console.log('Recieve join from ' + data.from)
|
console.log('Recieve join from ' + data.from)
|
||||||
if (game.owner == data.from || game.opponent.id == data.from) window.location.href = window.location.origin + '/lobby/' + game.id
|
|
||||||
if (game.owner != player.id) return // Only owner can process join
|
if (game.owner != player.id) return // Only owner can process join
|
||||||
game.join(data.from)
|
game.join(data.from)
|
||||||
break
|
break
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user