consik/yii2-websocket

ucfirst seems to not do its part

adzadzadz opened this issue · 4 comments

This is so weird, I've verified $command to be a String and also tested ucfirst with a static string and it works. But when ucfirst is used with $command ( ucfirst($command) ), it isn't returning as it should. Please refer to the screenshot. I will try and fix this in my end.
screen shot 2018-05-30 at 3 33 38 am

fixed the issue by removing the double quote since it's a json string
ucfirst(trim($command, '"'))

Proposed fix #11

show me your getCommand method?
You should normalize request to command name by overriding getCommand, not in onMessage method.

    protected function getCommand(ConnectionInterface $from, $msg)
    {
        return json_decode($msg)->action;
    }

Yeah I agree. I was thinking of shortening the process where all the $msgs are commands which isn't usually the case.

Anyway, I noticed that the connection closes for the frontend wherever I try to run an activerecord query such as User::findOne() but the connection in the server side is still running. Any insight with this?