let _state: any = {
  role: null,
  cid: null,
  roomId: null,
}

class Store {
  static getState() {
    return _state
  }

  static onMessage(message) {
    const { payload } = message
    switch (message.type) {
      case 'game_ready':
        const { cid, room_id, payload: { role } } = payload
        _state = {
          ..._state,
          cid,
          role, 
          roomId: room_id,
        } 
        break;
      case 'setUserInfo':
        _state = {
          ..._state,
          userInfo: payload
        }
      case 'updateCid':
        _state = {
          ..._state,
          cid: payload.cid
        }
      default:
        break;
    }
    return _state
  }  

  static isCatcher() {
    return true
    // return _state.role === 'ghost'
  }
}