Comments (5)
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.
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
Hope that helps & that you understand where I'm coming from!
Thanks
from sockette.
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.
@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.
@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)
- Disable reconnect programmatically HOT 15
- Access underlying socket object HOT 3
- SCRIPT5022: SecurityError in IE11 HOT 1
- onerror not returning code HOT 2
- ws.close should clear pending setTimeout HOT 1
- Still in CONNECTING state HOT 1
- Still reconnecting after close() HOT 5
- didunmount
- Bump npm version to include #48 HOT 1
- Able to detect network lost? HOT 1
- Possible to get WebSocket instance? HOT 1
- How to get error code HOT 1
- When I close the connection, it doesn't send queryStringParameters HOT 1
- Socket connection code choices HOT 2
- [Feature] Ability to set url before reconnecting HOT 1
- Increment timeout HOT 2
- Sockette.close can unexpectedly clear other timeouts/intervals
- project status? HOT 2
- Put an option to always reconnect, no matter what
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sockette.