H
H
hollanditkzn2017-05-19 17:06:28
Yii
hollanditkzn, 2017-05-19 17:06:28

How to setup widget on Yii2 yii2-node-socket?

It's a little unclear how to set up the yii2-node-socket widget. I'm getting errors in the console

GET crm/frontend/web/assets/c82ee7b9/client/client.js view?id=38:830
GET localhost:3001/socket.io/socket.io.js net::ERR_CONNECTION_REFUSED view?id=38:829
GET crm /frontend/web/assets/c82ee7b9/client/client.js view?id=38:830

And some things are a little unclear to me, let's say this fragment
###Events
###Work in javascript
Use YiiNodeSocket class
####Start work
// create object
var socket = new YiiNodeSocket();
// enable debug mode
socket.debug(true);

socket.onConnect(function () {
  // fire when connection established
});

socket.onDisconnect(function () {
  // fire when connection close or lost
});

socket.onConnecting(function () {
  // fire when the socket is attempting to connect with the server
});

socket.onReconnect(function () {
  // fire when successfully reconnected to the server
});

And the second point I have according to the documentation in
Register Yii component, need to add into frontend/config/main.php in your frontend application:
'nodeSocket' => [
        'class' => '\YiiNodeSocket\NodeSocket',
        'dbOptions' => '',
        'host' => 'localhost',
        'allowedServerAddresses' => [
            "localhost",
            "127.0.0.1"
        ],
        'origin' => '*:*',
        'sessionVarName' => 'PHPSESSID',
        'port' => 3001,
        'socketLogFile' => '/var/log/node-socket.log',
    ],

That is, an error occurs due to dbOptions, I had to remove this line
. And these commands are still incomprehensible
Use (./yii node-socket/)
$> ./yii node-socket/start # start server
$> ./yii node-socket/stop # stop server
$> ./yii node-socket/restart # restart server
$ > ./yii node-socket/get-pid # show pid of nodejs process

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