title: Ember Data with Websockets
body: <p>In the ember guides on models it says (<a href="http://emberjs.com/guides/models/" rel="nofollow">1</a>) :</p>
  
  <blockquote>
    <p>Ember Data is also designed to work with streaming APIs like socket.io, Firebase, or WebSockets. You can open a socket to your server and push changes to records into the store whenever they occur. </p>
  </blockquote>
  
  <p>I tried writing a custom adapter that uses a websocket but i'm not getting very far. I couldn't find any working examples anywhere.</p>
  
  <p>This is my totally unfinished prototype:</p>
  
  <pre><code>DS.WSAdapter = DS.Adapter.extend(Ember.Evented, {
  
      websocket: undefined,
  
      init: function () {
          if(this.websocket === undefined)
          {
              this.websocket = new WebSocket('ws://localhost:8887');
  
              this.websocket.onopen = function(e) {
                  console.log("Connection established!");
  
              };
              this.websocket.onmessage = function(e) {
                  // What to do here?
              }; 
          }
  
          this._loadData();
      },
  
      //....
  </code></pre>
  
  <p>Can somone please help me with the websocket adapter?</p>
  
  <p>My main problem is that I have no clue what to do when the <code>websocket.onmessage()</code> gets executed. I can't even access the store (using <code>DS.get('defaultStore')</code>) or anything </p>