Assessing socket out of framework.websocket callback

27 views
Skip to first unread message

José Marques

unread,
Jul 5, 2014, 9:19:40 PM7/5/14
to tot...@googlegroups.com
I have managed to broadcast messages using a global variable inside of the default js like this:
______________________________________________________________________________________________
exports.install = function(framework) {
    framework.route('/', index);
    framework.route('/route2',route_callback);
    framework.websocket('/', socket_callback, ['json']);
};

var global_socket;

function socket_callback(){
     global_socket = this;
};

function route_callback(){
     global_socket.send({type: 'msg' , message: 'ALLO'});
}
______________________________________________________________________________________________


But is there any native way to do this? 


Peter Širka

unread,
Jul 6, 2014, 5:05:40 AM7/6/14
to tot...@googlegroups.com
Hi José,
currently is your solution best way how to send websocket message from a classic controller.
I'll think about it.

Contact me if you will have some problem.
Thanks.
Reply all
Reply to author
Forward
0 new messages