Giter VIP home page Giter VIP logo

Comments (4)

bcc32 avatar bcc32 commented on August 13, 2024 1

In that case, perhaps there should be two interfaces, one that uses bytes and is free to trash the buffer when it's done, and one that uses string, so that this unexpected behavior is clearer?

from ocaml-websocket.

vbmithr avatar vbmithr commented on August 13, 2024

Ha I think this is because I mask the frame in-place before sending it to the client, as the websocket protocol requires. The right thing to do is indeed probably to make a copy of the content and not mask-in-place to avoid the issue you encountered. So option 2 :)

from ocaml-websocket.

copy avatar copy commented on August 13, 2024

I think for performance reasons the current behaviour should be kept or be enabled with a parameter. That's also how high-performance WebSocket libraries like uws do it.

from ocaml-websocket.

zoggy avatar zoggy commented on August 13, 2024

Since I upgraded to 2.7 today, I have a (maybe) related problem when accessing the content of received frames. I have no simple repro case but here is what I do:

  let handler conn_client =
        let req = Websocket_lwt.Connected_client.http_request conn_client in
        let recv () = Websocket_lwt.Connected_client.recv conn_client in
        let send = Websocket_lwt.Connected_client.send conn_client in
        let stream = Websocket_lwt.mk_frame_stream recv in
        <handle stream of frames>
  in
  let (waiter, stopper) = Lwt.wait () in
      let thread = Websocket_lwt.establish_standard_server
        ~stop: waiter ~ctx ~mode:server handler
      in
      Lwt.return { stopper ; thread }

When handling the stream of frames, I ignore the frames with opcode <> Websocket_lwt.Frame.Opcode.Text but the content of Text frames seems to be binary data.

from ocaml-websocket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.