yii-node-socket
yii-node-socket copied to clipboard
NodeSocket and its behaviors do not have a method or closure named "createEventFrame".
Hi, I very happy when I did find your extension. I need especially a solution like this. I did everithing above, git clone what needed and I also extend the config files. After that the npm install finishes its work in the .../server folder, So, everithing is done.
But when I try to start the server in the console by yiic node-socket start, it do nothing, only:
C:\xampp\htdocs\myapp\framework>yiic node-socket
Yii command runner (based on Yii v1.1.14)
Usage: C:\xampp\htdocs\myapp\framework\yiic
The following commands are available:
- message
- migrate
- shell
- webapp
To see individual command help, use the following:
C:\xampp\htdocs\myapp\framework\yiic help
And when I try to http://localhost/myapp/nsEventExample/sendEvent
it writes NodeSocket and its behaviors do not have a method or closure named "createEventFrame".
Could you help me in this?
Hi, about a console command, maybe you paste Console command map property in other section? Did you paste into console config?
Elsewhere you can set command folder as paramayer for yiic
Can you show me you config files?
And yii::app()->nodeSocket. Does not have createEventFrame, instead you should use factory with method
Yii ::app()->nodeSocket ->getFrameFactory->createEventFrame
Отправлено с MiPhone
Attila Szabó [email protected] писал:
Hi, I very happy when I did find your extension. I need especially a solution like this. I did everithing above, git clone what needed and I also extend the config files. After that the npm install finishes its work in the .../server folder, So, everithing is done.
But when I try to start the server in the console by yiic node-socket start, it do nothing, only:
C:\xampp\htdocs\myapp\framework>yiic node-socket Yii command runner (based on Yii v1.1.14) Usage: C:\xampp\htdocs\myapp\framework\yiic [parameters...]
The following commands are available:
messagemigrateshellwebapp
To see individual command help, use the following: C:\xampp\htdocs\myapp\framework\yiic help
And when I try to http://localhost/myapp/nsEventExample/sendEvent
it writes NodeSocket and its behaviors do not have a method or closure named "createEventFrame".
Could you help me in this?
— Reply to this email directly or view it on GitHub.
Yes of course I can: the console: return array( 'basePath' => dirname(FILE) . DIRECTORY_SEPARATOR . '..', 'name' => 'My Console Application',
'commandMap' => array(
'node-socket' => 'application.extensions.yii-node-socket.lib.php.NodeSocketCommand'
)
);
and the main: return array( 'basePath' => dirname(FILE) . DIRECTORY_SEPARATOR . '..', 'name' => 'myApp',
// preloading 'log' component
'preload' => array(
'log',
'nodeSocket',
),
// autoloading model and component classes
'import' => array(
'application.models.*',
'application.components.*',
),
'defaultController' => 'site',
// GII
'modules' => array(
'gii' => array(
'class' => 'system.gii.GiiModule',
'password' => 'gii',
),
),
// application components
'components' => array(
'user' => array(
// enable cookie-based authentication
'allowAutoLogin' => true,
),
// uncomment the following to use a MySQL database
'db' => array(),
'errorHandler' => array(
// use 'site/error' action to display errors
'errorAction' => 'site/error',
),
'urlManager' => array(
'showScriptName' => false,
'caseSensitive' => false,
'urlFormat' => 'path',
'appendParams' => false,
'rules' => array(
'login' => 'site/login',
'logout' => 'site/logout',
'register' => 'register/index',
'gii' => 'gii',
'gii/<controller:\w+>' => 'gii/<controller>',
'gii/<controller:\w+>/<action:\w+>' => 'gii/<controller>/<action>',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
array(
'class' => 'CFileLogRoute',
'levels' => 'error, warning',
),
),
),
// Socket component
// http://www.yiiframework.com/extension/yii-node-socket/
// https://github.com/oncesk/yii-node-socket
'nodeSocket' => array(
'class' => 'application.extensions.yii-node-socket.lib.php.NodeSocket',
'host' => gethostbyname('localhost'), // default is 127.0.0.1, can be ip or domain name, without http
'port' => 3001 // default is 3001, should be integer
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params' => require(dirname(__FILE__) . '/params.php'),
);
hm, did you run yiic into protected directory of your application?
Uhhh, there was an invalid .htaccess in the protected folder. Now happened something new. :)
C:\xampp\htdocs\myApp\protected>yiic node-socket start Error: Please provide valid socket transport component name like in config
USAGE yiic node-socket [action] [parameter]
DESCRIPTION This command provides support for node socket extension
EXAMPLES
- yiic node-socket start ........
You saw my config files. Is there the right component names?
Add component configuration to console config
Отправлено с MiPhone
Attila Szabó [email protected] писал:
Yes of course I can: the console: return array( 'basePath' => dirname(FILE) . DIRECTORY_SEPARATOR . '..', 'name' => 'My Console Application',
'commandMap' => array( 'node-socket' => 'application.extensions.yii-node-socket.lib.php.NodeSocketCommand' )
);
and the main: return array( 'basePath' => dirname(FILE) . DIRECTORY_SEPARATOR . '..', 'name' => 'myApp',
// preloading 'log' component 'preload' => array( 'log', 'nodeSocket', ), // autoloading model and component classes 'import' => array( 'application.models.', 'application.components.', ), 'defaultController' => 'site', // GII 'modules' => array( 'gii' => array( 'class' => 'system.gii.GiiModule', 'password' => 'gii', ), ), // application components 'components' => array( 'user' => array( // enable cookie-based authentication 'allowAutoLogin' => true, ), // uncomment the following to use a MySQL database 'db' => array(), 'errorHandler' => array( // use 'site/error' action to display errors 'errorAction' => 'site/error', ), 'urlManager' => array( 'showScriptName' => false, 'caseSensitive' => false, 'urlFormat' => 'path', 'appendParams' => false, 'rules' => array( 'login' => 'site/login', 'logout' => 'site/logout', 'register' => 'register/index', 'gii' => 'gii', 'gii/controller:w+' => 'gii/
', 'gii/controller:w+/action:w+' => 'gii/ / ', 'controller:w+/id:d+' => ' /view', 'controller:w+/action:w+/id:d+' => ' / ', 'controller:w+/action:w+' => ' / ', ), ), 'log' => array( 'class' => 'CLogRouter', 'routes' => array( array( 'class' => 'CFileLogRoute', 'levels' => 'error, warning', ), ), ), // Socket component // http://www.yiiframework.com/extension/yii-node-socket/ // https://github.com/oncesk/yii-node-socket 'nodeSocket' => array( 'class' => 'application.extensions.yii-node-socket.lib.php.NodeSocket', 'host' => gethostbyname('localhost'), // default is 127.0.0.1, can be ip or domain name, without http 'port' => 3001 // default is 3001, should be integer ), ), // application-level parameters that can be accessed // using Yii::app()->params['paramName'] 'params' => require(dirname(FILE) . '/params.php'), );
— Reply to this email directly or view it on GitHub.
Pfff... Now this is the same like before. I put the nodeSocket component also into the console.php. yiic simply writes the usage informations and commands. Nothing more.
How could I debug? Or where can I see any error information or somethig result message?
Hm, i do not fully understand, can you try set up extension again?
Error in prev comment was show because nodeSocket not found in Yii::app()->getComponent
Отправлено с MiPhone
Attila Szabó [email protected] писал:
Pfff... Now this is the same like before. I put the nodeSocket component also into the console.php. yiic simply writes the usage informations and commands. Nothing more.
How could I debug? Or where can I see any error information or somethig result message?
— Reply to this email directly or view it on GitHub.
Please help me. I use Ubuntu 14.04 When I start server: Log here: thaitv@thaitv-Lenovo-G470:~/jobs/php/workspaces/mn/protected$ php yiic node-socket start Compile server Compile client Starting server Server successfully started Update pid in file /home/thaitv/jobs/php/workspaces/mn/protected/runtime/socket-transport.pid thaitv@thaitv-Lenovo-G470:~/jobs/php/workspaces/mn/protected$
When i run example app, i have issue "NodeSocket and its behaviors do not have a method or closure named "createEventFrame". "
My config/console.php return array( 'basePath'=>dirname(FILE).DIRECTORY_SEPARATOR.'..',
// application components
'components'=>array(
'nodeSocket' => array(
'class' => 'application.extensions.yii-node-socket.lib.php.NodeSocket',
'host' => 'localhost', // default is 127.0.0.1, can be ip or domain name, without http
'port' => 3001 // default is 3001, should be integer
)
),
'commandMap' => array(
'node-socket' => 'application.extensions.yii-node-socket.lib.php.NodeSocketCommand'
)
);
And config/main.php
dirname(**FILE**).DIRECTORY_SEPARATOR.'..', 'name'=>'My Web Application', ``` // preloading 'log' component 'preload'=>array( 'log', 'nodeSocket' ), 'import'=>array( 'application.models.*', 'application.components.*', ), 'modules'=>array( ), // application components 'components'=>array( 'nodeSocket' => array( 'class' => 'application.extensions.yii-node-socket.lib.php.NodeSocket', 'host' => 'localhost', // default is 127.0.0.1, can be ip or domain name, without http 'port' => 3001 // default is 3001, should be integer ), 'user'=>array( 'allowAutoLogin'=>true, ), 'db'=>array( 'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db', ), 'errorHandler'=>array( // use 'site/error' action to display errors 'errorAction'=>'site/error', ), 'log'=>array( 'class'=>'CLogRouter', 'routes'=>array( array( 'class'=>'CFileLogRoute', 'levels'=>'error, warning', ), ), ), ), 'params'=>array( 'adminEmail'=>'[email protected]', ), ``` );
hi, try use Yii::app()->nodeSocket->getFrameFactory()->createEventFrame();
instead of Yii::app()->nodeSocket->createEventFrame();
and can you show your code?
Here my source code. I clone from example
render('index'); } public function actionSendEvent() { $event = Yii::app()->nodeSocket->createEventFrame(); $event->setEventName('event.example'); $event['data'] = array( 1, array( 'red', 'black', 'white' ), new stdClass(), 'simple string' ); $event->send(); $this->render('sendEvent'); } public function actionSendRoomEvent() { $event = Yii::app()->nodeSocket->createEventFrame(); $event->setRoom('example'); $event->setEventName('example.room.event'); $event['type_string'] = 'hello world'; $event['type_array'] = array(1, 2, 3); $event['type_object'] = array('one' => 1, 'two' => 2); $event['type_bool'] = true; $event['type_integer'] = 11; $event->send(); $this->render('sendRoomEvent'); } public function actionEventListener() { Yii::app()->nodeSocket->registerClientScripts(); $this->render('eventListener'); } ``` }
I try $event = Yii::app()->nodeSocket->getFrameFactory()->createEventFrame();
still have error
And why i can see anything log,info... in terminal? My terminal is thaitv@thaitv-Lenovo-G470:~/jobs/php/workspaces/mn/protected$ php yiic node-socket stop Stopping socket server Server successfully stopped Update pid in file /home/thaitv/jobs/php/workspaces/mn/protected/runtime/socket-transport.pid thaitv@thaitv-Lenovo-G470:~/jobs/php/workspaces/mn/protected$
what log do you need?
nodejs logs into runtime/socket-transport.server.log
I want realtime log in console. Does it have?
you can run it manually, into lib/js/server/
node server.js
but when you change some parameters into configs you need recompile nodejs config
and you error strange, do you shure what you call right action into controller? because this very strange
and what version of extension you use?
I call "index.php?r=nsEventExample/sendEvent" Yii 1.0 Nodejs version 0.10.30
yii-node-socket update from github
could you send me a project demo?
public function actionTestInvoke() { $frame = Yii::app()->nodeSocket->getFrameFactory()->createInvokeFrame(); $frame->invokeFunction('alert', array('Hello')); $frame->send(); }
public function actionTestRoom() {
$frame = Yii::app()->nodeSocket->getFrameFactory()->createEventFrame();
$frame->setEventName('event');
$frame->setRoom('test');
$frame['testsss'] = 12;
$frame->send();
}
public function actionSendUserEvent() {
$e = Yii::app()->nodeSocket->getFrameFactory()->createEventFrame();
$e->setEventName('test');
$e->send();
$event = Yii::app()->nodeSocket->getFrameFactory()->createUserEventFrame();
$event->setUserId(Yii::app()->user->getId());
$event->setEventName('single');
$event['test'] = 1;
$event->send();
}
this is my code and it works fine
examples contains old version
Woa, It works fine. But in client don't show anything :(
because view not render, this actions only for send events =) for tests
Okie, i understand. thanks you so much. :+1: :* :*
ok :)