MetinSeylan / Vue-Socket.io

😻 Socket.io implementation for Vuejs and Vuex
https://metin.sh
MIT License
3.95k stars 499 forks source link

socket actions with a boolean payload fail to catch a false value #311

Closed Kahss closed 3 years ago

Kahss commented 3 years ago

Hi,

I have an action which may receive a boolean parameter. However, it seems it always consider the false values as undefined. I have to use this trick to ensure that it does what I want

    socket_playerTurn(context: ActionContext<GameStateData, RootStateData>, myTurn: boolean) {
        if (myTurn === undefined) {
            myTurn = false;
        }
        context.commit('set_turn', myTurn);
    },

The action works when myturn === true but not when myturn === false, any idea why ?

Kahss commented 3 years ago

It seems that the problem is located in socket.io rather than here, mea culpa.