Socket.IO Support Extension for Twee.io Framework - MVC Framework for Node.js based on Express.js
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.npmignore
README.md
index.js
package.json

README.md

twee-socket-extension

Twee.io Logo

Gitter npm npm

Socket.io Support for Twee.io Framework - MVC Framework for Node.js and io.js based on Express.js.

Installation

Edit package.json of your application:

"dependencies": {
    "twee-socket-extension": "*"
}

Enable extension in application/configs/twee.js:

module.exports = {
    "extensions": {
        "Sockets": {
            "module": "twee-socket-extension"
        }
    }
};

Example of usage in modules/Default/controllers/DefaultController.js:

"use strict";

/**
* @type Object Default Controller
*/
module.exports = function () {
    /**
    * Main Page
    *
    * @param req
    * @param res
    */
    this.indexAction = function (req, res) {
        var self = this;

        res.render('Default/views/pages/Default/index');

        // Using sockets here.
        // Or we can use them before render
        // (not optimized for UI responsiveness)
        twee.get('socket.io').on('connect', function(socket){
            socket.emit('chat message', 'Hello from socket callback!');
        });
    };
};