Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

How can I set broadcaster/key/cluster/enabledTransports parameters? #28

Open
anonym24 opened this issue Apr 26, 2023 · 0 comments
Open

Comments

@anonym24
Copy link

So JS has the following implementation and it works:

class MyEcho {
  constructor(token) {
    this.echo = new Echo({
      broadcaster: 'pusher',
      key: process.env.REACT_APP_PUSHER_APP_KEY,
      cluster: process.env.REACT_APP_PUSHER_APP_CLUSTER,
      wsHost: process.env.REACT_APP_SOCKET_HOST,
      wsPort: 6001,
      enabledTransports: ['ws', 'wss'],
      auth: {
        headers: {
          Authorization: `Bearer ${token}`,
        },
      },
      authorizer: (channel) => {
        return {
          authorize: (socketId, callback) => {
            const data = {
              socket_id: socketId,
              channel_name: channel.name,
            };
            window.socketIdMain = socketId;
            api
              .post(WEB_API_ROUTES.auth.broadcastingAuth, data)
              .then((response) => {
                callback(null, response.data);
              })
              .catch((error) => {
                callback(error);
              });
          },
        };
      },
      forceTLS: false,
      encrypted: true,
      disableStats: true,
    });
  }

For Android I could only set host, port and token:

    val options = EchoOptions().apply {
        host = SERVER_URL // for example: "https://socket.example.com:6001"
        headers["Authorization"] = "Bearer $token"
        authEndpoint = "/broadcasting/auth"
        //eventNamespace = "App.Events" // not sure what is that, does it equal "broadcaster" of JS library?
    }

    echo = Echo(options).also {
        it.connect(
            { args ->
                Timber.d("ChatSocket successful connected: ${args.joinToString(", ")}")
                listenForEvents()
            },
            { args ->
                Timber.d("ChatSocket error while connecting: ${args.joinToString(", ")}")
            }
        )
    }

How can I configure all other parameters - broadcaster/key/cluster/enabledTransports?

Right now I can the error on connect ChatSocket error while connecting: io.socket.engineio.client.EngineIOException: xhr poll error

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant