Skip to content

Alternative for implementing Sink on WebsocketConnection #15

@Charles-Schleich

Description

@Charles-Schleich

Hello !
So I'm looking for guidance regarding alternatives to implementing Sink for WebsocketConnection as raised in #3
I effectively need the behavior of being able to split up the stream into a tx and an rx so I can store the tx in a Arc<Mutex<Hashmap<ID, tx>>> and use in my application elsewhere.

stream.split() looked like a good way of achieving this but seeing as its not the plan for this crate to support Sink,
how can I achieve something like this ?

app.at("/ws")
    .with(WebSocket::new(|_request, mut stream| async move {
        let (tx,rx) = stream.split();
        // tx is then put inside my Arc-Mutex-HashMap and use it elsewhere 
        Ok(())
    }))
    .get(|_| async move { Ok("You're not a websocket, shoo") });

Or a better question, is there a better way of going about keeping track of multiple WebsocketConnection's such that I have access to the tx of them ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions