Nodejs Websocket Extension

If you need create more live application this extension helps you with it.


  • emit events to all connected clients

  • create rooms and emit events into some room

  • set up data in nodejs memory from php and get in from javascript

  • invoke any function or method of object

  • use JQuery frame for javascript DOM manipulations on client side

Installation see on github project page, link below


before use register client scripts


var socket = new YiiNodeSocket();

// subscribe on updateBoard event

socket.on('updateBoard', function (data) {

    // do any action

});'testRoom').join(function (success, numberOfRoomSubscribers) {

    // success - boolean, numberOfRoomSubscribers - number of room members

    // if error occurred then success = false, and numberOfRoomSubscribers - contains error message

    if (success) {

        console.log(numberOfRoomSubscribers + ' clients in room: ' + roomId);

        // do something

        // bind events

        this.on('join', function (newMembersCount) {

            // fire on client join


        this.on('data', function (data) {

            // fire when server send frame into this room with 'data' event


    } else {

        // numberOfRoomSubscribers - error message





send event

// create event frame

$frame = Yii::app()->nodeSocket->createEventFrame();

// set event name


// set data using ArrayAccess interface

$frame['boardId'] = 25;

$frame['boardData'] = $html;

// or you can use setData(array $data) method

// setData overwrite data setted before


invoke javascript function on all clients from php

$invokeFrame = Yii::app()->nodeSocket->createInvokeFrame();

$invokeFrame->invokeFunction('alert', array('Hello world'));

$invokeFrame->send();   // alert will be showed on all clients

DOM manipulation:

// Update product in your application

$product = Product::model()->findByPk(21);

$product->price = $newPrice;

if ($product->save()) {

    // register scripts



    $jqueryFrame = Yii::app()->nodeSocket->createJQueryFrame();


        ->createQuery('#product' . $product->id)





Into your javascript

var socket = new YiiNodeSocket();

and price will be updated automatically on all connected clients immediately

sorry, but, this is a first posted extension here and i can not attach github link, only like a text, remove space after https and link will be valid

https ://

Hello Oncek… is it mandatory to use Linux for this ext sorry I was just wondering if there are other way around to use this ext on windows? please inform me thanks…

Hi, seems like problems will be with console command

Now in use next commands:

  • ps

  • kill

  • node

  • nohup

i am not a windows user, sorry

You can try do it, i will help you if i can =)

If you can find way it will be great

PS: please, write your next questions on github project page

Hi, look at the 0.1 branch on github, you can try implement ConsoleInterface in console/WinConsole.php class