In Ember you'd probably want to have a high level controller/route that sets up the sock. Then when a message comes in, assuming that the data
property of the message is the JSON representation of a model you can use push
on the store
. Something like this should do it:
App.Message = DS.Model.extend({...});
App.ApplicationRoute = Ember.Route.extend({
setupController : function(controller, model){
var sock = new SockJS('/echo');
var store = this.get('store');
sock.onmessage = function(e){
store.push('message',e.data);
}
}
});