Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a supply that notifies WebSocket Clients of closed connection #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

holli-holzer
Copy link

No description provided.

@Altai-man
Copy link
Member

What's the use case for this? Currently, when the server closes its connection, messages supply closes and that's an indication one wants.

@holli-holzer
Copy link
Author

holli-holzer commented Jan 4, 2020

It'd be niceto be able to stay in the react/whenever semantics and get notified of a closing connection. Basically

my $conn = try await Cro::WebSocket::Client.connect( $some-server );

react 
{
    whenever $conn.messages -> $message 
    {
        say "Incoming: ", await $message.body;
    }

    whenever $conn.closing -> $reason
    {
        say "Closing: $reason";
        done;
    }
    
    whenever $user-input.command -> $command 
    {
        $conn.send( $command );
        CATCH { say "Error sending <$command>: {.message}" }
    }
};

If you have an alternative that is equally pretty or at least functional, please share.

Background: https://www.perlmonks.org/?node_id=11110913

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants