Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
LocomotiveJS and Socket.IO
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rui  
View profile  
 More options Apr 13 2012, 1:29 pm
From: Rui <ruimgoncal...@gmail.com>
Date: Fri, 13 Apr 2012 10:29:08 -0700 (PDT)
Local: Fri, Apr 13 2012 1:29 pm
Subject: LocomotiveJS and Socket.IO

Hi again

Been playing around with SocketIO and trying to get it to work with
Locomotive.
I succeeded in doing this, but its kind of an hack.

What is the best way to achieve this?

File - all.js
<code>
module.exports = function() {
    .....

require('socket.io').listen(this._routes._http).sockets.on('connection',
function (socket) {
        console.log("Connection");
      socket.emit('news', { hello: 'world' });
    });

}

</code>

Best regards


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jared Hanson  
View profile  
 More options Apr 13 2012, 1:46 pm
From: Jared Hanson <jaredhan...@gmail.com>
Date: Fri, 13 Apr 2012 10:46:24 -0700 (PDT)
Local: Fri, Apr 13 2012 1:46 pm
Subject: Re: LocomotiveJS and Socket.IO

Thanks for pushing the envelope on these early Locomotive versions.  

I'd recommend checking out the master branch, which is where v0.2.0 is
being worked on, and doing development with that (npm link it, if you
wish).  One of my goals for that is to cleanly expose a standard Express
instance so socket.io and the like can be layered on easily.

When doing that, you wouldn't use the built-in lcm command line to start
the server, but rather write your own short myserver.js file, containing
something like the following:

myserver.js

    var locomotive = require('locomotive');

    // Boot Locomotive.  Loads routes, controllers, etc from the file system
    // and calls back with a fully configured express instance.
    locomotive.boot('./path/to/app', 'development', function(err, express) {
      if (err) { throw err; }

      // Hookup socket.io.  Any other module that runs on top of HTTP could
      // be configured here too.
      require('socket.io').listen(express);

      // start Express listening for requests
      express.listen(port, address, function() {
        var addr = this.address();
        debug('listening on %s:%d', addr.address, addr.port);
      });
    });

Thats it!  Now you can just run node myserver.js, and Locomotive will load
up your MVC web app and hand you an Express instance for further
customization and layering, and you can listen when ready.

I think its going to be pretty slick.  Let me know what you think.

Jared


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Duncan Wong  
View profile  
 More options Apr 29 2012, 1:09 pm
From: Duncan Wong <baduncadun...@gmail.com>
Date: Sun, 29 Apr 2012 10:09:37 -0700 (PDT)
Local: Sun, Apr 29 2012 1:09 pm
Subject: Re: LocomotiveJS and Socket.IO

I see the rationale.  I like the transparency and customization, but not
the boilerplate.  Would a default file be auto-generated from the lcm
command?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jared Hanson  
View profile  
 More options Apr 29 2012, 1:27 pm
From: Jared Hanson <jaredhan...@gmail.com>
Date: Sun, 29 Apr 2012 10:27:48 -0700
Local: Sun, Apr 29 2012 1:27 pm
Subject: Re: LocomotiveJS and Socket.IO

Yeah, that's an interesting idea.  For most MVC-only apps, I figure the
default `lcm server` command is sufficient, and there's no need to further
customize the boot process.

It'd be nice to define some conventions surrounding this, though.  Perhaps
a "config/listeners" directory (not sure the best name), that contains
scripts that attach other protocols (Socket.io, DNode, etc.) to Express.
 I'll mull it over.  Let us know if you have any ideas.

Jared

On Sun, Apr 29, 2012 at 10:09 AM, Duncan Wong <baduncadun...@gmail.com>wrote:

--
Jared Hanson <http://jaredhanson.net/>

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Denis Wolf  
View profile  
 More options Oct 4 2012, 11:11 am
From: Denis Wolf <den...@wix.com>
Date: Thu, 4 Oct 2012 08:11:41 -0700 (PDT)
Local: Thurs, Oct 4 2012 11:11 am
Subject: Re: LocomotiveJS and Socket.IO

Hi, Jared

It has been a while since 0.2 and now those 'hacks' don't work thx to the
changes in Express3, I assume.
Is there a simple method to connect socket.io v.9 to locomotive 3.1 ?)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marcus Koosmann  
View profile  
 More options Jan 21, 1:36 am
From: Marcus Koosmann <koosm...@gmail.com>
Date: Sun, 20 Jan 2013 22:36:52 -0800 (PST)
Local: Mon, Jan 21 2013 1:36 am
Subject: Re: LocomotiveJS and Socket.IO

I'm also having trouble using these techniques to get SocketIO running on
Locomotive 0.3 (on Express 3).  Is there any way to get it working with
these versions?

Thanks,
-Marcus


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Denis Wolf  
View profile  
 More options Jan 21, 4:07 am
From: Denis Wolf <den...@wix.com>
Date: Mon, 21 Jan 2013 01:07:26 -0800 (PST)
Local: Mon, Jan 21 2013 4:07 am
Subject: Re: LocomotiveJS and Socket.IO

In the end I went for a 'dirty way' and required it as separate module than
processed IO as another high-level component and required it's connection
altogether with model in controller.

look at https://github.com/deniswolf/Fetish
particularly at:
https://github.com/deniswolf/Fetish/blob/master/config/initializers/0...
https://github.com/deniswolf/Fetish/blob/master/app/sockets/entities_...
https://github.com/deniswolf/Fetish/blob/master/app/controllers/entit...

it's not the best way to handle things and I run socket.io on separate
port, but it works good enough.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roland Flanagan  
View profile  
 More options Mar 26, 9:26 pm
From: Roland Flanagan <flanama...@gmail.com>
Date: Tue, 26 Mar 2013 18:26:24 -0700 (PDT)
Local: Tues, Mar 26 2013 9:26 pm
Subject: Re: LocomotiveJS and Socket.IO

To get around this, I used this to bind it to express 3.0

server.listen(port, address, function() {
    io.listen(this);
    var addr = this.address();
    console.log('listening on %s:%d', addr.address, addr.port);


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »