@@ -40,19 +40,19 @@ enum SocketConnectionState { notConnected, handshake, connecting, connected }
40
40
enum ToggleConnectionState { disconnect, connect }
41
41
42
42
class SocketClientConfig {
43
- const SocketClientConfig ({
44
- this .serializer = const RequestSerializer (),
45
- this .parser = const ResponseParser (),
46
- this .autoReconnect = true ,
47
- this .queryAndMutationTimeout = const Duration (seconds: 10 ),
48
- this .inactivityTimeout = const Duration (seconds: 30 ),
49
- this .delayBetweenReconnectionAttempts = const Duration (seconds: 5 ),
50
- this .initialPayload,
51
- this .headers,
52
- this .connectFn,
53
- this .onConnectionLost,
54
- this .toggleConnection,
55
- });
43
+ const SocketClientConfig (
44
+ { this .serializer = const RequestSerializer (),
45
+ this .parser = const ResponseParser (),
46
+ this .autoReconnect = true ,
47
+ this .queryAndMutationTimeout = const Duration (seconds: 10 ),
48
+ this .inactivityTimeout = const Duration (seconds: 30 ),
49
+ this .delayBetweenReconnectionAttempts = const Duration (seconds: 5 ),
50
+ this .initialPayload,
51
+ this .headers,
52
+ this .connectFn,
53
+ this .onConnectionLost,
54
+ this .toggleConnection,
55
+ this .pingMessage = const < String , dynamic > {} });
56
56
57
57
/// Serializer used to serialize request
58
58
final RequestSerializer serializer;
@@ -76,6 +76,9 @@ class SocketClientConfig {
76
76
/// If null, the reconnection will occur immediately, although not recommended.
77
77
final Duration ? delayBetweenReconnectionAttempts;
78
78
79
+ // The payload to send the send while pinging. If null payload while ping the server will be empty.
80
+ final Map <String , dynamic > pingMessage;
81
+
79
82
/// The duration after which a query or mutation should time out.
80
83
/// If null, no timeout is applied, although not recommended.
81
84
final Duration ? queryAndMutationTimeout;
@@ -413,7 +416,7 @@ class SocketClient {
413
416
_pingTimer? .cancel ();
414
417
_pingTimer = new Timer (
415
418
config.inactivityTimeout! ,
416
- () => _write (PingMessage ()),
419
+ () => _write (PingMessage (config.pingMessage )),
417
420
);
418
421
}
419
422
0 commit comments