happones / nativescript-laravel-echo

A nativescript plugin for laravel-echo
Apache License 2.0
10 stars 2 forks source link

Any way to use this with tightenco/laravel-websockets? #15

Open ggportfoliowork opened 4 years ago

ggportfoliowork commented 4 years ago

Is it possible to use this plugin with https://github.com/beyondcode/laravel-websockets?

Laravel Websockets functions as a replacement for Pusher, while still utilizing Pusher functionality. I see that with this package there is an option to set a host, but the documentation says that's only available for Socket.IO? Is there any way to integrate both of these?

ggportfoliowork commented 4 years ago

I managed to get it working by modifying the core pusher-connector.js

Additional k/v pairs need to be appended to the instantiated options object including:

wsHost httpHost wsPort wssPort disableStats encrypted

Are you open to PR's @happones ?

emperorjm commented 4 years ago

There is actually no need to make any changes to the code. You simply need to add the required options to make your custom server work, namely: wsHost and wsPort. You can view other options here: https://github.com/pusher/pusher-js. I was able to get the package working with the two options I added above.

marquipaul commented 4 years ago

@emperorjm I did the same and it works fine. I ca see the connection on /laravel-websockets now. But it can't subscribe into a private channel but it can on a public channel. This is my sample code I have a private and public channel: Screenshot from 2020-03-25 09-52-50

.But it only show the public channel subscription I also add authorization

Screenshot from 2020-03-25 09-57-53

Screenshot from 2020-03-25 09-53-55

marquipaul commented 4 years ago

Hello guys I solved the problem my problem by adding android:usesCleartextTraffic="true" on my AndroidManifest.xml since every time you subscribe on a private channel it will send an http request to your server to authenticate the user by using the authEndpoint with Authorization Bearer token.