Giter Club home page Giter Club logo

Comments (5)

lukeed avatar lukeed commented on August 20, 2024 1

Sure – I know what I posted is far from complete, but the idea is that once you find/decide how you want to split up your messages, it's easily attached to a Sockette instance. I was just showing an example of that.

Interesting. For my purposes, those requests would live under the HTTP protocol, but it's probably not as interesting :P

from sockette.

lukeed avatar lukeed commented on August 20, 2024

Hi! Thanks :)

This wouldn't make it into Sockette unfortunately, mostly because of how easy it would be to achieve from the "outside" :

let ws = new Sockette(...);

// can add a new method for large payloads
// or can save & overwrite `ws.send` (chosen)
let send = ws.send.bind(ws);
ws.send = function (msg) {
  let len = msg.length;
  if (len < 32e3) return send(msg);
  
  for (let sent = 0; sent < len;) {
    send(msg.substring(sent, sent += 32e3));
  }
}

Warning: untested :)

I'm also not sure that this is a common need. I, for one, use WS a lot and have never come close to that limit 😬Curious what you need it for, haha

Hope that helps & that you understand where I'm coming from!

Thanks

from sockette.

rsshilli avatar rsshilli commented on August 20, 2024

This problem isn't super difficult but it's tougher than it looks. For example, your code above would break if msg is in Chinese (every char would take up 4 bytes). Also, there needs to be a basic protocol header so that the other side knows if the message has been broken up, when it's done, etc.

Still, I understand if this isn't Sockette's thing. I'll keep searching for a solution. We have a couple of large forms where people can enter a lot of data. Occasionally, but rarely, they cross this barrier. I'm surprised that I'm the first person to have to solve it.

from sockette.

spankyed avatar spankyed commented on August 20, 2024

@rsshilli Could you share the solution you came up with for this issue?

Edit: I found this tutorial on handling WebSocket frame boundaries in stream-based data using the STOMP protocol. But the solution is anything but easy to implement (or comprehend at the least).

from sockette.

rsshilli avatar rsshilli commented on August 20, 2024

@spankyed It's not a simple answer. It's ~100 lines of code for us that wouldn't make sense outside of our product (qbdvision.com). I'm sorry that I don't have something simple to share.

from sockette.

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.