useEffectState
hook: https://github.com/delucis/bgio-effects/blob/latest/src/react/hooks/useEffectState.ts
Hi! I'm trying to make the game work properly local (in different tabs) before trying to put it on a server. I don't know why but game is no syncing correctly, even I have two different component with different playerID. I'm using React Router <Route /> component to wrap each client, is this a problem?
This is my client
import { Client } from 'boardgame.io/react';
import { Local } from 'boardgame.io/multiplayer';
import MainBoard from './Board';
import { WsGame } from './Game';
import { EffectsBoardWrapper } from 'bgio-effects/react';
const main = EffectsBoardWrapper(MainBoard, {
updateStateAfterEffects: true,
speed: 1,
});
const Demo = Client({
game: WsGame,
board: main,
multiplayer: Local()});
export default Demo;
And I call it here
function App() {
return (
<Routes>
<Route exact path='/' element={<Home />} />
<Route exact path='/gacha' element={<Gacha />} />
<Route exact path='/arena' element={<Demo playerID='0'/>} />
<Route exact path='/arena2' element={<Demo playerID='1'/>} />
</Routes>
);
}
But runs two completely different game on each path
I've been mostly lurking here for a while. Over the past 2 years or so I've been working on and off (most of it was in mid-2020) on an online version of a game I like, Quacks of Quedlinburg: https://github.com/opollak/quack-quacks
I had it working locally for a while, and was able to play successfully with friends. Then I didn't touch it for a while, and came back to it recently to put it on Heroku. In the process I decided to update BGIO to the latest version, since I had been using one of the 0.39.X versions from the beginning. It seems that feature [01c522c] from v0.43.3 is now causing the app to throw an error, which didn't happen before.
I have a few classes that I created outside of the game const
, whose only function is a constructor. I call the constructor during game setup and then use the objects throughout the rest of the game; it was working totally fine in the older version of BGIO. Is my interpretation correct that I need to get rid of these classes and just use POJOs or arrays?
class Chip {
constructor(type, number) {
this.type = type;
this.number = number;
}
}
// becomes
function Chip(type, number) {
return { type, number };
}
@/all We’ll soon be releasing v0.50 which will come with a breaking change in how game moves and other functions are written.
You can see details of the change and migration instructions at this PR: boardgameio/boardgame.io#891
If anyone’s feeling like a brave early adopter, an alpha release is available today, you can get it by installing the alpha
release tag:
npm i boardgame.io@alpha
Let me know how migration goes. It would be helpful to know about any particular points before launching this as the main release.
Hey all, I've been using boardgame.io over the past year or so for a side project and I love it so far. Thank you for creating it!
I'm seeing some behaviour in the server that I find a bit strange and wanted to ask some folks closer to the project for their thoughts on it in case I'm misinterpreting what's going on.
I'm not currently using any form of persistence on my server, so when the server restarts any active games are lost. What's strange to me is that if a client from an old game is still active when the server restarts, the server seems to create a new game with the minimum player count (in my case, 2) and then tries to handle requests from the old clients on that new game.
In my case, this is causing my server to crash when the old game has more than the minimum number of players because my playerView
code is being called for a playerID
of "2" (or higher) for a new game that was setup for only 2 players. I could write more defensive code in the playerView
code to handle missing playerIDs the same as spectators, but it seems strange to me that this new game would get created in the first place. Is this intentional behaviour and should my code be accounting for playerID
s that don't exist in the active game, or is this a bug?
Hi all, I had a question regarding multiplayer client behavior. According to this doc https://boardgame.io/documentation/#/secret-state?id=disabling-moves-that-manipulate-secret-state-on-the-client clients will default to resolving moves on their own whereas we would need to specify that we only want the server to resolve the move due to gamestate incompatibility. Is there a doc regarding how/why clients behave in contrast to a non-multiplayer/local multiplayer state, and the tradeoffs?
I have a situation where my test server uses local multiplayer whose moves seem to have access to the hidden gamestate, but the deployed server doesn't. I figure the easiest way to solve this is to have all my moves execute as non-client, but I'm wondering if there's some optimization I'll be giving up (this is assuming the server also resolved the move to ensure the client is correct).
Client
with multiplayer: SocketIO({ server: bgServer })
bgioServer:80/socket.io/?EIO...
bgioServer/socket.io
and everything was working fine but suddenly somethign started adding por :80 to the url
Hi! I'm trying to deploy my app (front end on my server and server on heroku) and I'm getting this error in the frontend
arena:1 Access to XMLHttpRequest at 'https://ws-game-master.herokuapp.com/socket.io/?EIO=4&transport=polling&t=NwXsM7G' from origin 'https://www.world-seekers.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
and this error in the server log
2022-01-28T18:00:24.286135+00:00 app[web.1]: Server `origins` option is not set.
2022-01-28T18:00:24.286148+00:00 app[web.1]: Since boardgame.io@0.45, CORS is not enabled by default and you must explicitly set the origins that are allowed to connect to the server.
2022-01-28T18:00:24.286149+00:00 app[web.1]: See https://boardgame.io/documentation/#/api/Server
2022-01-28T18:00:24.323597+00:00 app[web.1]: server running 11469
2022-01-28T18:01:22.967180+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-01-28T18:01:23.026541+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-01-28T18:01:23.057766+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2022-01-28T18:01:23.175484+00:00 heroku[web.1]: Process exited with status 22
2022-01-28T18:01:23.242359+00:00 heroku[web.1]: State changed from starting to crashed
const { Server } = require('boardgame.io/server');
const { WsGame } = require('./Game');
const port = process.env.PORT || 8000
const server = Server({games: [WsGame]});
server.run(8000, () => console.log('server running ' + port ));
const { Server } = require('boardgame.io/server');
const { WsGame } = require('./Game');
const port = process.env.PORT || 8000
const server = Server(
{games: [WsGame],
origins: ['https://www.world-seekers.com/'] });
server.run(8000, () => console.log('server running ' + port ));
const PORT = process.env.PORT || 8000;
server.run(PORT, ...);
server.run(8000, () => console.log('server running ' + port ));
server running 11469
11469
but you’re actually using 8000
as the argument to server.run
.