Skip to content

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

Open
holli-holzer wants to merge 1 commit intocroservices:mainfrom
holli-holzer:master
Open

Added a supply that notifies WebSocket Clients of closed connection#25
holli-holzer wants to merge 1 commit intocroservices:mainfrom
holli-holzer:master

Conversation

@holli-holzer
Copy link
Copy Markdown

No description provided.

@Altai-man
Copy link
Copy Markdown
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
Copy Markdown
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