About geddy realtime

66 views
Skip to first unread message

X

unread,
May 13, 2014, 2:40:30 AM5/13/14
to ged...@googlegroups.com
Hey guys...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?

As usual, any help is much appreciated! Thanks guys!

X

unread,
May 13, 2014, 6:14:02 PM5/13/14
to ged...@googlegroups.com
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!');
   
});
});

Thoughts?

Matthew Eernisse

unread,
May 14, 2014, 12:31:15 PM5/14/14
to ged...@googlegroups.com
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:

Set a listener in your init.js for that event, and set your RT code up in there. Bear in mind that you can't do with with a clustered configuration because Socket.io is running in the same process as the server.

`geddy.model.<ModelType>` will emit lifecycle events you can listen for, documented here:

http://geddyjs.org/guide#models_lifecycle_events

Hope that gets you going.




--
The official community discussion group.
website: geddyjs.org, source: https://github.com/mde/geddy, group: https://groups.google.com/d/forum/geddyjs?hl=en
---
You received this message because you are subscribed to the Google Groups "GeddyJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geddyjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

X

unread,
May 14, 2014, 2:06:24 PM5/14/14
to ged...@googlegroups.com
Perfect! Thanks!

X

unread,
May 15, 2014, 2:06:15 PM5/15/14
to ged...@googlegroups.com
Hi Matt, quick question: what does Geddy do to make its models realtime? Other than the environment.js being:

var config = {
  realtime
: true
};


module.exports = config;

Is there anything else that Geddy does? I had created a model or two long back with the rt option, but since then, I've not used the terminal to generate a model but rather just created the file directly from my IDE.

I really don't need my models to support realtime as long as I can emit events from my controller, which I have verified that I can. I just wanted to make sure I clean up stuff that I'm not using.

Thoughts?

Thanks a lot!


On Wednesday, May 14, 2014 12:31:15 PM UTC-4, Matthew Eernisse wrote:

Matthew Eernisse

unread,
May 15, 2014, 2:13:27 PM5/15/14
to ged...@googlegroups.com
This is what Geddy uses to bootstrap the built-in RT:

https://github.com/geddy/geddy/blob/master/lib/init/realtime.js

All you'd need to do to emit realtime events from your controller would be a reference to your Socket.io instance.


X

unread,
May 15, 2014, 2:15:32 PM5/15/14
to ged...@googlegroups.com
Got it..Thanks!

elce...@gmail.com

unread,
Jul 17, 2014, 11:28:01 PM7/17/14
to ged...@googlegroups.com
Actually, he may want to do the same thing I did in the gist reffered to here: https://groups.google.com/forum/#!topic/geddyjs/BJuktbq_4UI

The realtime.js code you referred to below has 2 emitters that always emit.  Based on the OP's posts and other posts regarding authentication, I'm guessing he doesn't want those "automatic" emitters either.  In my case we're emitting from our models' before*/after* event handlers, so we didn't want anything else emitting events.  I could be wrong, but I thought I'd pipe up since I've been dealing with these same issues :-)
Reply all
Reply to author
Forward
0 new messages