braverhealth / phoenix-socket-dart

Cross-platform and stream-based implementation of Phoenix Sockets
https://pub.dev/packages/phoenix_socket
BSD 3-Clause "New" or "Revised" License
73 stars 37 forks source link

Provide access to WebSocket header when connecting to Pheonix Socket #44

Closed mehrdad-shokri closed 4 months ago

mehrdad-shokri commented 2 years ago

Here you are calling connect on WebSocketChannel https://github.com/braverhealth/phoenix-socket-dart/blob/70a437c11617505d280988f6204cb4b34ce66cc2/lib/src/socket.dart#L193
Please provide a Map<String, String> headers on the constructor of PhoenixSocket so we can pass our authentication cookies to the server.

Pacane commented 2 years ago

Would you mind opening a PR? I'd be glad to review it.

Thank you!

mehrdad-shokri commented 2 years ago

Sure, will do in the following days

RodolfoSilva commented 4 months ago

@mehrdad-shokri @Pacane

I think this solves your problem. This feature was added in this PR: https://github.com/braverhealth/phoenix-socket-dart/pull/71

return PhoenixSocket(
     "ws://localhost:4000/socket",
      webSocketChannelFactory: (uri) {
        return IOWebSocketChannel.connect(uri, headers: { "token": "My Token"});
      },
    );

@matehat - I think this issue is resolved.