Socket.io

569 views
Skip to first unread message

didier...@gmail.com

unread,
Dec 7, 2013, 5:34:44 AM12/7/13
to part...@googlegroups.com
Hi,

How to use Socket.io in partial.js? A configuration or a index.js file?
Thanks

Peter Širka

unread,
Dec 7, 2013, 5:46:07 AM12/7/13
to part...@googlegroups.com
Hi,

You do not need to use socket.io, why?

- partial.js supports websocket and works perfectly
- only you must write XHR alternative for older web browsers (but it's easy)

Thanks.

herman...@googlemail.com

unread,
Jan 23, 2014, 7:56:43 AM1/23/14
to tot...@googlegroups.com, part...@googlegroups.com
Today I tried to get primus.io working with the socket.io example, but I had no luck with it. This is my module:

var primusio = require('primus.io');

framework.on('load', function() {
this.primus = new primusio(this.server, { transformer: 'websockets', parser: 'JSON' });
});

Do you know why framework.primus is undefined in my controller?
I would also like to integrate a XHR solution for your framework, because I'm really interested in it. But my problem is, I don't know how to do it properly. Maybe you could give me a little advice. =)

Peter Širka

unread,
Jan 23, 2014, 8:02:18 AM1/23/14
to tot...@googlegroups.com, part...@googlegroups.com, herman...@googlemail.com
Hello,

Do you know why framework.primus is undefined in my controller?
Because current context is FrameworkController not Framework. You must use: framework.primus or self.framework.primus or:

framework.on('load', function() {
   
// this === framework, not controller

   
this.primus = new primusio(this.server, { transformer: 'websockets', parser: 'JSON' });
});


framework
.eval(function() {
   
Controller.prototype.primus = function() {
       
return framework.primus;
   
});
});

// controller.primus works now!

Thanks! :-)


Reply all
Reply to author
Forward
0 new messages