Building a chat application

In this recipe, we'll combine what you learned with initializers and dependency injection to create a chat room. The chat room will use WebSockets to communicate with the host.

How to do it...

  1. In a new application, generate these files:
    $ ember g service sockjs
    $ ember g component chat-room
    $ ember g initializer application
    $ bower install sockjs --save
    

    These will generate the files needed for the project. The chat-room component will have all the logic for the chat room that we'll create.

  2. Import the SockJS library to the application:
    // ember-cli-build.js
    …
    app.import('bower_components/sockjs/sockjs.min.js');
    …

    This will import the library so that we can use the global variable, sockjs, anywhere in our application.

  3. Create ...

Get Ember.js Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.