package io.scalecube.gateway.websocket;

import io.scalecube.gateway.clientsdk.ClientMessage;
import io.scalecube.gateway.clientsdk.ClientSettings;
import io.scalecube.gateway.clientsdk.codec.WebsocketGatewayMessageCodec;
import io.scalecube.gateway.clientsdk.websocket.WebsocketClientTransport;
import io.scalecube.services.codec.DataCodec;
import java.time.Duration;
import reactor.core.publisher.Mono;
import reactor.ipc.netty.resources.LoopResources;

public class WebsocketClientTransportTest {

  public static void main(String[] args) {
    String contentType = "application/json";
    ClientSettings settings =
        ClientSettings.builder().contentType(contentType).host("localhost").port(7070).build();
    LoopResources loopResources = LoopResources.create("worker");

    WebsocketClientTransport transport =
        new WebsocketClientTransport(
            settings,
            new WebsocketGatewayMessageCodec(DataCodec.getInstance(contentType)),
            loopResources);

    ClientMessage request = ClientMessage.builder().qualifier("/greeting/one").build();

    Mono.delay(Duration.ofSeconds(10))
        .doOnTerminate(
            () -> {
              System.err.println("closing ...");
              transport.close().subscribe();
            })
        .subscribe();

    ClientMessage block = transport.requestResponse(request).block();

    System.out.println(block);
  }
}

@@ -534,16 +534,44 @@
 %5B%5D args)
+ throws InterruptedException
  %7B%0A    S
@@ -1042,16 +1042,24 @@
 equest =
+%0A       
  ClientM
@@ -1102,16 +1102,35 @@
 g/one%22).
+header(%22sid%22, %221%22).
 build();
@@ -1169,10 +1169,9 @@
 nds(
-10
+3
 ))%0A 
@@ -1352,30 +1352,8 @@
 %0A   
- ClientMessage block =
  tra
@@ -1388,46 +1388,94 @@
 st).
-block();%0A%0A    System.out.println(block
+subscribe(System.out::println, System.err::println);%0A%0A    Thread.currentThread().join(
 );%0A 

Update WebsocketHandler and WebsocketSession behavior