kerimamansaryyev / dart_pusher_channels

MIT License
48 stars 13 forks source link

When will Encrypted channels be supported? #22

Closed samehdoush closed 1 year ago

samehdoush commented 1 year ago

Thank you for this great package, it's the only one currently working with flutter and websocket laravel Is there a soon date for the launch of support for Encrypted channels?

kerimamansaryyev commented 1 year ago

@samehdoush Hi, actually, I am planning to implement the feature in 2 upcoming months. But my biggest concern is that I need to test the encrypted channels. test.pusher.com supports only the presence channels. Could you please recommend any services to create the private encrypted channels for Pusher protocol?

samehdoush commented 1 year ago

@kerimamansaryyev If I create an ubuntu server + laravel project + (soketi or laravel websocket) and create a simple control panel to do experiments, does this help you?

kerimamansaryyev commented 1 year ago

@samehdoush That would be great! I am not server developer, can't configure hosting settings, though. Will this project be hosted somewhere?

samehdoush commented 1 year ago

@kerimamansaryyev The demo project has been added in: https://github.com/samehdoush/flutterWebsocket and auto deploy on server

I've put a simple example that currently only concerns encrypted channels (Send & Receive) on https://dart-pusher-channels.ps4tek.com/dashboard

https://github.com/samehdoush/flutterWebsocket/blob/main/README.md

I hope he can help you in adding the encrypted channels feature

Just create a new user and then go to the dashboard

Tell me if you want me to add types of public and private channel connections, etc...

kerimamansaryyev commented 1 year ago

@kerimamansaryyev The demo project has been added in: https://github.com/samehdoush/flutterWebsocket and auto deploy on server

I've put a simple example that currently only concerns encrypted channels (Send & Receive) on https://dart-pusher-channels.ps4tek.com/dashboard

https://github.com/samehdoush/flutterWebsocket/blob/main/README.md

I hope he can help you in adding the encrypted channels feature

Just create a new user and then go to the dashboard

Tell me if you want me to add types of public and private channel connections, etc...

It really means a lot to me and to my package, thank you for your support, I will start digging the case right from tomorrow!

kerimamansaryyev commented 1 year ago

@samehdoush could we communicate in some social media in case if some questions appear? Could you please send me your contacts to some of the social medias on my email - kerimamanwork@gmail.com ?

samehdoush commented 1 year ago

@kerimamansaryyev I sent the information to you by e-mail If you need anything, contact me

kerimamansaryyev commented 1 year ago

@samehdoush Got it, thank you!

kerimamansaryyev commented 1 year ago

@samehdoush The feature is ready and now it's in preview. Please visit the branch https://github.com/kerimamansaryyev/dart_pusher_channels/tree/feature/encrypted_channel

To check this out with an example:

  1. in pubspec.yaml
    dart_pusher_channels:
    git:
      url: https://github.com/kerimamansaryyev/dart_pusher_channels
      ref: feature/encrypted_channel
  2. Code sample. (Apply your credentials in the login API request):
    
    import 'dart:convert';

import 'package:dart_pusher_channels/dart_pusher_channels.dart'; import 'package:http/http.dart' as http;

void run() async { PusherChannelsPackageLogger.enableLogs(handler: print);

const hostOptions = PusherChannelsOptions.fromHost( scheme: 'wss', host: 'socketdemo.ps4tek.com', key: '30fad4c0b0b50a1a41ca', port: 443, );

final client = PusherChannelsClient.websocket( options: hostOptions, connectionErrorHandler: (exception, trace, refresh) {}, );

final loginResponse = await http.Client() .post(Uri.parse('https://dart-pusher-channels.ps4tek.com/api/login'), body: jsonEncode( { 'email': 'YOUR_USER_EMAIL', 'password': 'YOUR_USER_PASSWORD', 'device_name': 'YOUR_USER_DEVICE' }, ), headers: { 'Content-Type': 'application/json', });

final accessToken = jsonDecode(loginResponse.body)['access_token'] as String;

final authorizationDelegate = EndpointAuthorizableChannelTokenAuthorizationDelegate .forPrivateEncryptedChannel( authorizationEndpoint: Uri.parse( 'https://dart-pusher-channels.ps4tek.com/api/broadcasting/auth'), headers: { 'Authorization': 'Bearer $accessToken ', // token from api }, );

final privateChannel = client.privateEncryptedChannel( 'private-encrypted-user-test-2', authorizationDelegate: authorizationDelegate, );

privateChannel.bind('App\Events\UserTest').listen((event) { print('OBJECT ${event.rootObject}'); print('DATA ${event.tryGetDataAsMap()}'); });

client.onConnectionEstablished.listen((event) { privateChannel.subscribeIfNotUnsubscribed(); });

client.connect(); }

kerimamansaryyev commented 1 year ago

Implemented with PR #23