1616
1717package io .rsocket ;
1818
19+ import static io .rsocket .util .ExceptionUtil .noStacktrace ;
20+
1921import io .netty .buffer .Unpooled ;
2022import io .netty .util .collection .IntObjectHashMap ;
2123import io .rsocket .exceptions .ConnectionException ;
2224import io .rsocket .exceptions .Exceptions ;
2325import io .rsocket .internal .LimitableRequestPublisher ;
2426import io .rsocket .util .PayloadImpl ;
25- import org .reactivestreams .Publisher ;
26- import org .reactivestreams .Subscriber ;
27- import reactor .core .Disposable ;
28- import reactor .core .publisher .*;
29-
30- import javax .annotation .Nullable ;
3127import java .nio .channels .ClosedChannelException ;
3228import java .time .Duration ;
3329import java .util .Collection ;
3632import java .util .function .Consumer ;
3733import java .util .function .Function ;
3834import java .util .function .Supplier ;
39-
40- import static io .rsocket .util .ExceptionUtil .noStacktrace ;
35+ import javax .annotation .Nullable ;
36+ import org .reactivestreams .Publisher ;
37+ import org .reactivestreams .Subscriber ;
38+ import reactor .core .Disposable ;
39+ import reactor .core .publisher .*;
4140
4241/** Client Side of a RSocket socket. Sends {@link Frame}s to a {@link RSocketServer} */
4342class RSocketClient implements RSocket {
@@ -53,7 +52,7 @@ class RSocketClient implements RSocket {
5352 private final IntObjectHashMap <Subscriber <Payload >> receivers ;
5453 private final AtomicInteger missedAckCounter ;
5554
56- private final EmitterProcessor < Frame > sendProcessor ;
55+ private final FluxProcessor < Frame , Frame > sendProcessor ;
5756
5857 private @ Nullable Disposable keepAliveSendSub ;
5958 private volatile long timeLastTickSentMs ;
@@ -82,7 +81,7 @@ class RSocketClient implements RSocket {
8281
8382 // DO NOT Change the order here. The Send processor must be subscribed to before receiving
8483 // connections
85- this .sendProcessor = EmitterProcessor .create ();
84+ this .sendProcessor = EmitterProcessor .< Frame > create (). serialize ();
8685
8786 if (!Duration .ZERO .equals (tickPeriod )) {
8887 long ackTimeoutMs = ackTimeout .toMillis ();
@@ -91,7 +90,7 @@ class RSocketClient implements RSocket {
9190 started
9291 .thenMany (Flux .interval (tickPeriod ))
9392 .doOnSubscribe (s -> timeLastTickSentMs = System .currentTimeMillis ())
94- .flatMap (i -> sendKeepAlive (ackTimeoutMs , missedAcks ))
93+ .concatMap (i -> sendKeepAlive (ackTimeoutMs , missedAcks ))
9594 .doOnError (
9695 t -> {
9796 errorConsumer .accept (t );
@@ -425,7 +424,7 @@ protected void cleanup() {
425424 synchronized (RSocketClient .this ) {
426425 subscribers = receivers .values ();
427426 publishers = senders .values ();
428-
427+
429428 senders .clear ();
430429 receivers .clear ();
431430 }
0 commit comments