Ember data and Websockets / SockJS


#1

After much thinking about which route I would like to go when refactoring a web application which previously used server side rendering, I now almost came to the conclusion that I want to handle all my connections via websockets. Not just for the fun of it, but I can see some very tempting advances of how to get all the needed data to the client. Unfortunately I haven’t found much information about how ember data plays together with websockets. Preferably I would like to use SockJS which offers fallback solutions in case the websocket can not be established. Secondly I would like to refactor the backend to use vertx, which in terms provides a full server side SockJS implementation [2].

I have found one or two custom implementations of adapters to use websockets like [1], but currently nothing to use SockJS. Has anyone already tried to accomplish that? If not I would really like to give that a try, but I am pretty new to ember and the whole websocket thing, so any pointers where to start are much welcome.

[1] https://gist.github.com/carlwoodward/8659793 [2] http://vertx.io/core_manual_groovy.html#sockjs


#2

http://emberjs.com/guides/models/pushing-records-into-the-store/


#3

@Hummingbird I’ve experimented with a SocketSource using Orbit.js to use a socket for resources (data w/ json payloads) rather than using the socket only for sending messages. Here are some of my discoveries so far: https://gist.github.com/pixelhandler/5389c72c82d26fae8fb1 once the ember-orbit project is released, I’ll finish up the SocketSource (addition for Orbit.js) to use with that library.


#4

Thanks, i have already seen that. However if I understand that correctly I would still need to write an adapter in order to query for a required set of data?


#5

Thanks, that is quite interesting. However it seems you did not give any answer to the question why you did not use ember data, unless I overlooked it. Has it just been at a too early stage or are there any other reasons why this hasn’t been feasible?


#6

yup, unless someone already came out with one. It shouldn’t be too hard to write though.


#7

@Hummingbird I wasn’t interested in writing a socket adapter for Ember Data as I was more interested in a store that has transactions between multiple stores, e.g. memory, localStorage, remote DB via web socket.


#8

Thanks, awesome. I think that’s all I needed to know for now :slight_smile: