Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

message event #2

Closed
hij1nx opened this Issue · 6 comments

2 participants

Paolo Fragomeni Max Ogden
Paolo Fragomeni

I'm not sure how/why e has an assumed structure (https://github.com/maxogden/websocket-stream/blob/master/index.js#L35). I replaced this with e.data || e but perhaps there was some other intent here that I'm not aware of.

Also, I was trying to do something like levelup.readStream({ limit: 10 }).pipe(stream); on the server and it didn't work. I think pipe might be broken because the data event is returning undefined in its callback. :hamster:

Max Ogden
Owner

in web browsers websockets take functions like this: websocket.onmessage = function(e) {} where e is an object with a data key that contains the actual data and the rest of the keys in e are metadata. how were you instantiating your websocket and what environment were you in?

Paolo Fragomeni

yes correct, this is all taking place on the server in the index.js file that i cited in the issue.

Paolo Fragomeni

I should probably clarify further -- your wrapper (on the server) assumes that e will have structured data (e.data = value) passed into it, but it doesn't, instead it just gets value as a result of the client's socket.write() call.

Max Ogden
Owner
Paolo Fragomeni

Yes im using the ws module -- the one you are using in your example. I'll put together a specific test for this when I get a spare cycle.

Max Ogden
Owner
Max Ogden maxogden closed this issue from a commit
Max Ogden check for data property on chunk and emit that if present, otherwise …
…emit the whole thing (fix for browser+server compatibly). closes #2
875a87c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.