Comments (1)
First of all, I did not quite get the idea of some of your questions (also I cannot understand how get_user_id()
relates to tokio-tungstenite), but I'll try my best to answer your question.
If I got you right, you want to check the incoming user (upon reception of incoming websocket handshake request) and drop it if certain conditions for this particular user are not met, in your case you check the "condition" by doing some work around executing redis futures.
It is possible to implement what you want, but if your redis future depends on incoming WS-handshake header values, then there will be a portion of "blocking code" in your headers callback, i.e. you have to spawn/wait for a redis future to complete inside a callback (there are several ways to accomplish this, you may want to choose the one which better fits your needs).
As for returning a future from the headers callback -- currently it's not possible, we would need to update some tokio-tungstenite (and probably tungstenite) APIs to allow such chaining to support this behavior, but I got your point and it's BTW a good enhancement request -- returning future instead of a plain Result<>
totally makes sense in tokio-tungstenite! Feel free to create a corresponding issue, so that we can mark it as an enhancement and consider its implementation. I don't plan to work on this particular enhancement in the near future (there are still some pending issues in tungstenite/tokio-tungstenite which have higher priority for us at the moment), but feel free to create a new pull request if you by chance can work on the implementation of this feature.
Hopefully I was able to answer your tungstenite related questions, so I would consider this issue as closed.
from tokio-tungstenite.
Related Issues (20)
- Question/Help Needed: How to properly handle a WebSocket close? HOT 1
- How do I get current length of send buffer? HOT 1
- Headers validation checking. HOT 4
- WebSocket protocol error: Connection reset without closing handshake.
- Can't disable certificate validation HOT 1
- I want to configure a larger number of concurrent connections for the server. How should I configure it?
- Consider closing stream if reader was dropped HOT 1
- Using a Tor connector from `arti-client` HOT 1
- Add feature to use rustls instead of native-tls HOT 1
- `TcpListener::accept` blocks runtime after accepting a websocket connection HOT 2
- What's Proper way to close a connection after split? HOT 1
- `tokio-tungstenite` + `SkipServerVerification` + `rustls ` seems never works HOT 2
- SendAfterClosing when doing the close handshake in 0.20.1 HOT 4
- Update to tungstenite 0.21 HOT 3
- `rustls-tls-native-roots` does not imply `rustls-tls-native-roots` for `tungstenite` HOT 3
- Passing body in `connect`? HOT 2
- Can we provided a way to keep the original header name case. HOT 1
- 403 Forbidden HOT 1
- "WebSocket protocol error: httparse error: invalid token" when connect from ngrok tcp tunnel. HOT 5
- Is it possible to bind client to specific interface? HOT 1
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 tokio-tungstenite.