03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Real Time Chat 196<br />

43 <br />

.<br />

This was extracted from app/views/index/index.blade.php.<br />

You’ll notice, apart from us using different field names; that we’ve change how the loop is done, the<br />

class added to each “label” cell and how the input field is generated.<br />

The reason for the change to the loop structure is simply so that you can see another way to<br />

represented enumerable data in handlebars. Where previously we used a simple {{#each}} tag, we’re<br />

now being more explicit about the data we want to iterate.<br />

We add a special class on each “label” cell as we need to target these cells and change their contents,<br />

in the event that a user decides to change their name.<br />

Finally, we change how the input field is generated because we need to bind its value to the<br />

IndexController’s command property. This format allows that succinctly.<br />

.<br />

You can learn more about Ember JS at: http://emberjs.com/.<br />

Note On Nginx<br />

For persistent sockets to remain open, Apache needs to keep a single process thread occupied. This<br />

is a problem as it will consume vast amounts of RAM over a shorter time period than non-persistent<br />

connections would. For this reason; I highly recommend using either Nginx or an event-based<br />

language to create your chat application.<br />

It’s not that Apache sucks; this is just not the sort of thing it was designed for. Nginx, on the other<br />

hand, is event-based and doesn’t hold onto a whole thread while it waits for activity through the<br />

open socket.<br />

.<br />

You can learn more about Nginx at: http://wiki.nginx.org/Main.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!