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

make headers editable #63

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/src/realtime_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RealtimeClient {
String? accessToken;
List<RealtimeChannel> channels = [];
final String endPoint;
final Map<String, String> headers;
final Map<String, String> _headers;
final Map<String, dynamic> params;
final Duration timeout;
final WebSocketTransport transport;
Expand All @@ -55,6 +55,11 @@ class RealtimeClient {
int eventsPerSecondLimitMs = 100;
bool inThrottle = false;

/// Getter for the headers
Map<String, String> get headers {
return _headers;
}

/// Initializes the Socket
///
/// `endPoint` The string WebSocket endpoint, ie, "ws://example.com/socket", "wss://example.com", "/socket" (inherited host & protocol)
Expand All @@ -81,7 +86,7 @@ class RealtimeClient {
this.params = const {},
this.longpollerTimeout = 20000,
}) : endPoint = '$endPoint/${Transports.websocket}',
headers = {
_headers = {
...Constants.defaultHeaders,
if (headers != null) ...headers,
},
Expand Down