如何允许同一socket.io房间中的人访问同一redux存储?

时间:2019-04-24 22:44:50

标签: javascript reactjs redux

如果他们在同一个socket.io房间中,我需要多个用户才能访问同一个Redux商店。

我尝试了一些教程。

https://github.com/Shubanshii/mad-hatter-server/tree/master/client

我在Game.jsx的reducer的数组中添加了一个播放器

    Game.jsx
...
this.props.dispatch(addPlayer(userInfo));
...

/reducers/index.js
...
switch (action.type) {
...
    case actions.ADD_PLAYER:
      handleAddPlayer();

      break;

...

function handleAddPlayer() {
    let player = {
      index: 0,
      userInfo: action.userInfo,
      stackSize: 100,
      inHand: true,
      playerTurn: true,
      playerIndex: 0,
      smallBlind: true,
      bigBlind: false,
      contributedTowardsToPlay: 0,
      hasChecked: false
    };
    modifiedState.playerInfo.push(player);
  }

我希望能够登录一个选项卡,然后切换到隐身窗口,以其他用户身份登录,然后加入同一房间,并在两个选项卡中让Redux商店显示两个玩家。

0 个答案:

没有答案
相关问题