twee-socket-extension
v0.0.4
Published
Socket.io Extension for Twee.io Framework - MVC Framework for Node.js based on Express.js
Downloads
5
Maintainers
Readme
twee-socket-extension
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!');
});
};
};