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.
On Friday, April 13, 2012 10:46:24 AM UTC-7, Jared Hanson wrote:
> 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
> On Friday, April 13, 2012 10:29:08 AM UTC-7, Rui wrote:
>> 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.
On Friday, April 13, 2012 10:46:24 AM UTC-7, Jared Hanson wrote:
> 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
> On Friday, April 13, 2012 10:29:08 AM UTC-7, Rui wrote:
>> 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.
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:
> 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?
> On Friday, April 13, 2012 10:46:24 AM UTC-7, Jared Hanson wrote:
>> 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
>> On Friday, April 13, 2012 10:29:08 AM UTC-7, Rui wrote:
>>> 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.
> On Friday, April 13, 2012 10:46:24 AM UTC-7, Jared Hanson wrote:
>> 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
>> On Friday, April 13, 2012 10:29:08 AM UTC-7, Rui wrote:
>>> 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.
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 ?)
On Sunday, April 29, 2012 8:27:48 PM UTC+3, Jared Hanson wrote:
> 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 <badunc...@gmail.com<javascript:> > > wrote:
>> 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?
>> On Friday, April 13, 2012 10:46:24 AM UTC-7, Jared Hanson wrote:
>>> 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
>>> On Friday, April 13, 2012 10:29:08 AM UTC-7, Rui wrote:
>>>> 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.
>> On Friday, April 13, 2012 10:46:24 AM UTC-7, Jared Hanson wrote:
>>> 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
>>> On Friday, April 13, 2012 10:29:08 AM UTC-7, Rui wrote:
>>>> 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.
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?
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.
On Monday, January 21, 2013 8:36:52 AM UTC+2, Marcus Koosmann wrote:
> 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
> On Friday, 13 April 2012 10:29:08 UTC-7, Rui wrote:
>> 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.
}); On Monday, January 21, 2013 8:07:26 PM UTC+11, Denis Wolf wrote:
> 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.
> it's not the best way to handle things and I run socket.io on separate > port, but it works good enough.
> On Monday, January 21, 2013 8:36:52 AM UTC+2, Marcus Koosmann wrote:
>> 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
>> On Friday, 13 April 2012 10:29:08 UTC-7, Rui wrote:
>>> 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.