Getting Started With WebSockets And Ember

So what are WebSockets? A WebSocket is a protocol that allows communication over TCP in web browsers and web servers. In most instances you have a server and a client and they communicate with each other over a socket.

You might remember I created a basic Socket.IO tutorial using Express and Node in a previous post. It was really easy to setup and work with. Today I'll be looking into using the latest ember-websockets addon by Travis Hoover.

Unfortunately the addon doesn't work with Socket.IO so we'll be using another web socket library called ws. It works almost the same way as Socket.IO.

Getting Started On Node

We aren't going to get into too much detail on setting up the Node server. We are essentially just seeing if we can get communication going.

Now we won't get any unusual errors in the console or have issues connecting. The EmberJS WebSockets Addon is a service. So for us to use it we'll need to inject it into all our controllers. Earlier I generated an initializer. We'll go ahead and use that to inject the websocket service.