WebSocket client API
Pavel Rappo
pavel.rappo at oracle.com
Wed Oct 21 10:52:55 UTC 2015
> On 19 Oct 2015, at 22:37, Simone Bordet <simone.bordet at gmail.com> wrote:
>
> Now I am confused :)
>
> Are you saying that if you do:
>
> builder.headers("foo", "bar", "baz").headers("one", "two", "three")
>
> then "foo", "bar" and "baz" are removed ?
In the current version it is exactly like you've said. And we're gonna change
it! The only thing is, it should've been:
builder.headers("name1", "value1", "name2", "value2").headers("name3", "value3")
instead of what you've written. In this case custom headers would've been
("name3", "value3") as `.headers("name3", "value3")` was the last call and
therefore it would've overwritten preceding `.headers("name1", "value1",
"name2", "value2")`
>> Easier? In some cases, probably. On the other WebSocket.request(long) is an
>> internal part of the API that only the Listener should talk to (the same is with
>> Flow.Subscriber and Flow.Subscription).
>
> In proxies and WebSocket applications in general, it's the opposite:
> these applications want to call request(long) after they have written
> data, not after they read it, to produce backpressure.
...
>> But I'm against of merging flowController with WebSocket.
>
> Yet, you did not bring any technical reasons for the split, and
> "separation of concerns" is just not enough because it can mean
> anything (and it may even be wrong).
I see what you mean, but my passage above does not contradict this. What I
wanted to say (but it seems like I've failed the attempt) is that Listener is
pretty much Flow.Subscription. And as such is susceptible to Rule 3.1 [1]. There
are some subtle differences though between general Flow case and out WebSocket
case! The most obvious one is that WebSocket has a single Subscriber --
WebSocket.Listener.
> If you write a chat application with these API, you will see that
> having WebSocket.request() simplifies the code by *a lot*.
>
> I have done that, and I am reporting my impressions.
Do you still have any examples? I would love to see them.
-------------------------------------------------------------------------------
[1] https://github.com/reactive-streams/reactive-streams-jvm/
More information about the net-dev
mailing list