Trying to deal with the work of Websocet seemed to find a normal solution and downloaded the add-ons did everything according to the instructions, except put the Chat3WebsocketDaemonHandler class in the console / models folder and in the config / console / config / main.php

'websocket' => [ 'class' => 'morozovsk\yii2websocket\Connection', 'servers' => [ 'chat3' => [ 'class' => 'console\models\Chat3WebsocketDaemonHandler', 'pid' => '/tmp/websocket_chat.pid', 'websocket' => 'tcp://127.0.0.1:8004', 'localsocket' => 'tcp://127.0.0.1:8010', //'master' => 'tcp://127.0.0.1:8020', //'eventDriver' => 'event' ] ], ], 

he himself took this class from you from here, but a little bit was modified to such

 <?php namespace console\models; class Chat3WebsocketDaemonHandler extends \morozovsk\websocket\Daemon { protected function onOpen($connectionId, $info) { //call when new client connect to server $message ="yes"; } protected function onClose($connectionId) { //call when existing client close connection } protected function onMessage($connectionId, $data, $type) { //call when new message from existing client $message = "user #{$connectionId}: $data"; //send message to all client foreach ($this->clients as $clientId => $client) { $this->sendToClient($clientId, $message); } } } 

now I try to start like this ./yii websocket / start chat3 and the reaction is not something that would be zero but this is the reaction

and if I start to write something like this, I understand that this chat should not work that way, can you tell me where I’ve been on

    1 answer 1

    Start chat via nohup yii websocket/start chat3 & So you will not have to hang the process and the web socket server will be running. But there is a nuance, if you do not constantly use chat, the server will fall off. So here you will need to come up with yourself, maybe by interval do ping => pong so to speak.

    • it is under Linux so, on ubunt (mint) nohup was originally there, if you don’t then install, under ubunt like this: apt-get install nohup - Turkish Gambit