@@ -81,8 +81,6 @@ class RealtimeClient {
81
81
};
82
82
int longpollerTimeout = 20000 ;
83
83
SocketStates ? connState;
84
- int eventsPerSecondLimitMs = 100 ;
85
- bool inThrottle = false ;
86
84
87
85
/// Initializes the Socket
88
86
///
@@ -122,11 +120,6 @@ class RealtimeClient {
122
120
if (headers != null ) ...headers,
123
121
},
124
122
transport = transport ?? createWebSocketClient {
125
- final eventsPerSecond = params['eventsPerSecond' ];
126
- if (eventsPerSecond != null ) {
127
- eventsPerSecondLimitMs = (1000 / int .parse (eventsPerSecond)).floor ();
128
- }
129
-
130
123
final customJWT = this .headers['Authorization' ]? .split (' ' ).last;
131
124
accessToken = customJWT ?? params['apikey' ];
132
125
@@ -288,7 +281,6 @@ class RealtimeClient {
288
281
///
289
282
/// If the socket is not connected, the message gets enqueued within a local buffer, and sent out when a connection is next established.
290
283
String ? push (Message message) {
291
- final event = message.event;
292
284
void callback () {
293
285
encode (message.toJson (), (result) => conn? .sink.add (result));
294
286
}
@@ -297,18 +289,7 @@ class RealtimeClient {
297
289
message.payload);
298
290
299
291
if (isConnected) {
300
- if ([
301
- ChannelEvents .broadcast,
302
- ChannelEvents .presence,
303
- ChannelEvents .postgresChanges
304
- ].contains (event)) {
305
- final isThrottled = _throttle (callback)();
306
- if (isThrottled) {
307
- return 'rate limited' ;
308
- }
309
- } else {
310
- callback ();
311
- }
292
+ callback ();
312
293
} else {
313
294
sendBuffer.add (callback);
314
295
}
@@ -487,17 +468,4 @@ class RealtimeClient {
487
468
));
488
469
setAuth (accessToken);
489
470
}
490
-
491
- bool Function () _throttle (Function callback, [int ? eventsPerSecondLimit]) {
492
- return () {
493
- if (inThrottle) return true ;
494
- callback ();
495
- inThrottle = true ;
496
- Timer (
497
- Duration (
498
- milliseconds: eventsPerSecondLimit ?? eventsPerSecondLimitMs),
499
- () => inThrottle = false );
500
- return false ;
501
- };
502
- }
503
471
}
0 commit comments