Skip to content

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