Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does the client receive messages sent by the server #240

Open
sdack-cloud opened this issue Aug 8, 2022 · 2 comments
Open

How does the client receive messages sent by the server #240

sdack-cloud opened this issue Aug 8, 2022 · 2 comments
Labels
needs triage Issue/PR needs triage by a project maintainer

Comments

@sdack-cloud
Copy link

sdack-cloud commented Aug 8, 2022

Websocketclient receives routing message

@viglucci
Copy link
Member

viglucci commented Aug 8, 2022

Hi @sdack-cloud , are you able to provide any additional information into what issue you are having?

@sdack-cloud
Copy link
Author

sdack-cloud commented Aug 8, 2022

                    clientRSocket = RSocketConnector.create()
                        .metadataMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.string)
                        .dataMimeType(WellKnownMimeType.APPLICATION_JSON.string)
                        .setupPayload(DefaultPayload.create("ttest"))
                        .acceptor(
                            SocketAcceptor.forRequestResponse { payload: Payload ->
                                val route: String? = decodeRoute(payload.sliceMetadata())
                                payload.release()
                                if ("message" == route) {
                                    val meta = MetaVo.Meta.parseFrom(payload.data)
                                    Log.e("MESSAGE", meta.toString())
                                    Mono.just(meta)
                                }
                                Mono.error(IllegalArgumentException("Route $route not found"))
                            }
                        )
                        .keepAlive(Duration.ofSeconds(30), Duration.ofMinutes(30))
                        .reconnect(Retry.fixedDelay(4, Duration.ofSeconds(5)))
                       .block()
     this.connector = new RSocketConnector({
        setup: {
          keepAlive: 5 * 1000,
          lifetime: 10 * 1000, //存活时长 毫秒
          dataMimeType: WellKnownMimeType.APPLICATION_CBOR.string,
          metadataMimeType: WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.string,
          // dataMimeType: "application/octet-stream",
          // metadataMimeType: 'message/x.rsocket.composite-metadata.v0',//message/x.rsocket.composite-metadata.v0
          payload: {
            data: Buffer.from("vue"),
            // metadata: encodeSimpleAuthMetadata("user","pass"),
          }
        },
        responder: {
          accept: () => ({
            requestResponse: (payload) => {
              console.log("payload")
            }
          })
        },
        transport: new WebsocketClientTransport({
          debug: true,
          url: 'ws://localhost:7002',
        }),
      });
      this.connector
        .connect()
        .then((res) => {
          console.log("connect", res)
          this.rsocketRequester = res;
          window.rsocketRequester = res;
          this.rsocketRequester.onClose((err) => {
            console.log("CLOSE", err)
          })
        }).catch((err) => {
        console.error("connect", err);
      });

How does the JS client receive routing messages ,Like Java acceptor(), it receives the information from the server

There are too few examples. Can you add some examples
@viglucci

@viglucci viglucci added the needs triage Issue/PR needs triage by a project maintainer label Aug 13, 2022
@sdack-cloud sdack-cloud changed the title Websocketclient receives routing message How does the client receive messages sent by the server Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue/PR needs triage by a project maintainer
Projects
None yet
Development

No branches or pull requests

2 participants