Frage

I have a Geddy app that has some realtime models (I remember using -rt to generate some models), and I'd like to revisit the realtime-ness of my Geddy app.

I don't need my models to be updated automatically (I'm not sharing models with the client; I am using Geddy only as a REST backend)

But I would like to explicitly emit events through socket.io and use its room functionality in my controllers, and I'll handle those events in the client side appropriately.

So, my questions are: 1. how do I clean up my existing code in that I don't want realtime models in my app 2. what would I need to do in order to explicitly events from my controllers?

I tried doing the following in after_start.js as shown here: https://github.com/geddy/geddy/wiki/Realtime-and-MVC in "Realtime for existing projects" section, but none of the messages get logged...

console.log('Here 1');
geddy.io.sockets.on('connection', function(socket) {
    console.log('Here 2');
    socket.emit('hello', {message: "world"});
    socket.on('message', function(message) {
        console.log('Message!');
    });
});

Any help is much appreciated. Thanks!

War es hilfreich?

Lösung

Just found out that the after_start.js was a workaround for the lack of events from the application to know when the server had actually started (so you would know when you could attach Socket.io). Now the geddy object in the worker process emits a 'started' event you can use:

http://geddyjs.org/reference#global

So set a listener in your init.js for that event, and set your RT code up in there.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top