Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bottling #19

Open
dcharbonnier opened this issue Nov 30, 2017 · 2 comments
Open

bottling #19

dcharbonnier opened this issue Nov 30, 2017 · 2 comments

Comments

@dcharbonnier
Copy link
Owner

dcharbonnier commented Nov 30, 2017

AKA json-streaming with filter

@dcharbonnier dcharbonnier modified the milestones: 0.2.0, 0.3.0 Nov 30, 2017
@dcharbonnier dcharbonnier removed this from the 0.3.0 milestone Dec 13, 2017
@kmannislands
Copy link

Would this be required to use it with ShareDB on the server?
Trying to understand how this fits in with WebSocketJSONStream. Client API makes sense but I don't get how to put a pipe in front of ShareDB on the server.

@kmannislands
Copy link

Figured it out. My issue was actually #101

For future readers (if the interface hasn't been fixed in the library), to work with ShareDB on the server, the following did the trick for me:

import { Pipe } from 'hydrated-ws'

// the sole purpose of this is to patch the interface
class EmitterPipe extends Pipe {
  on(event, cb) {
    return this.addEventListener(event, (msg) => cb(msg.data));
  }
}

const wss = new WebSocket.Server();

wss.on('connection', (ws) => {
  const ShareDBChannel = new EmitterPipe(ws, 'SDB');
  const stream = new WebSocketJSONStream(ShareDBChannel);
  this.share.listen(stream);
});

When the fix for #101 lands, sounds like the patch class won't be necessary and when bottling lands, the WebSocketJSONStream won't be necessary either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants