Giter Club home page Giter Club logo

Comments (1)

daniel-abramov avatar daniel-abramov commented on July 16, 2024 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)

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.