K
K
Konstantin Marchenko2018-06-14 20:38:42
Yii
Konstantin Marchenko, 2018-06-14 20:38:42

Yii2 websocket connect in controller?

Hello! people tell me how to use yii2 websockets? I installed from here: https://github.com/consik/yii2-websocket
Everything works great. But there was a need to send commands and messages not from javascript, but from php. I can't figure out how to connect a socket in the controller and apply it. Tried like this:

public function action***() {
            $event = new WSClientMessageEvent;
            $event->message = 'awdawdawd';
            $this->trigger(self::EVENT_CLIENT_MESSAGE, $event);
}

does not work .... Tell me how to use them?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question