title: How does Rsocket server send message to client? And how to use Channel in js?
body: <p>everyone.</p>
  
  <h2>Question 1</h2>
  
  <p>I try to use Rsocket.  How does Rsocket server send message to client?  Like websocket, the server can send message to one client or all clients. I can not find a way to do it. Maybe I can use Channel? But I do not know what to do.</p>
  
  <h2>Question 2</h2>
  
  <p>I use Channel like this:</p>
  
  <pre class="lang-kotlin prettyprint-override"><code>  @MessageMapping("channel")
    fun channel(settings: Flux&lt;Duration&gt;) =
        settings
            .doOnNext { setting: Duration -&gt; println("Frequency setting is ${setting.seconds} second(s).") }
            .switchMap { setting: Duration -&gt;
              Flux.interval(setting).map { index: Long -&gt; Message("Server", "Channel", index) }
            }
            .log()
  </code></pre>
  
  <p>And in js, I do this:</p>
  
  <pre class="lang-js prettyprint-override"><code>const {
    RSocketClient
  } = require('rsocket-core');
  const RSocketTcpClient = require('rsocket-tcp-client').default;
  const {Flowable} = require('rsocket-flowable')
  
  const tcpClient = new RSocketTcpClient((host, port))
  
  const client = new RSocketClient({
    setup: {
      keepAlive,
      lifetime,
      dataMimeType: "application/json",
      metadataMimeType: 'message/x.rsocket.routing.v0'
    },
    transport: tcpClient,
  });
  
  const flowablePayload = new Flowable(subscriber =&gt; {
    subscriber.onSubscribe({
      cancel: () =&gt; {},
      request: n =&gt; {
        for (let index = 0; index &lt; n; index++) {
          const message = {
            message: "requestChannel from JavaScript! #" + index
          };
          subscriber.onNext(message);
        }
        subscriber.onComplete();
      }
    });
  });    
  
  client.connect().subscribe({
    onComplete: socket =&gt; {
      console.log('onComplete')
      socket.requestChannel({
        data: flowablePayload,
        metadata: String.fromCharCode('channel'.length) + 'channel'
      }).subscribe({
        onComplete: res =&gt; console.log(res),
        onError: err =&gt; console.error(err)，
        onSubscribe: cancel =&gt; console.log('success')
      });
    },
    onError: error =&gt; {
      console.log("got error");
      console.error(error);
    },
    onSubscribe: cancel =&gt; {
      console.log("subscribe!");
    }
  })
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>subscribe!
  onComplete
  success
  </code></pre>
  
  <p>But I can not get the <code>MessageMapping</code> channel info and <code>channel</code> method is not executed.</p>
  
  <p>What should I do？</p>
  
  <p>Thanks!!!</p>