Open anonym24 opened 1 year ago
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
ChatSocket error while connecting: io.socket.engineio.client.EngineIOException: xhr poll error
So JS has the following implementation and it works:
For Android I could only set host, port and token:
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