Class socketio.backoff
Exponential backoff Used internally by transports when one socket.io's server does not respond to calculate the duration to wait before trying back.
Inspired from https://www.npmjs.com/package/backo2
Functions
C.new (opts) | Class constructor |
Methods
socketio.backoff:duration (self) | Returns duration to wait and consider a new attempt is imminent. |
socketio.backoff:reset (self) | Reset the attempt counter, meaning server did respond. |
Functions
- C.new (opts)
-
Class constructor
Parameters:
- opts Table of options
- hello Table of options
- min Minimum duration in second (default: 0.1)
- max Maximum duration in second (defalut: 1)
- factor Multiplication factor to duration after each attempt (default: 2)
- jitter Duration jitter (default: 0)
Returns:
-
instance
- opts Table of options
Methods
- socketio.backoff:duration (self)
-
Returns duration to wait and consider a new attempt is imminent.
Calling this method increases the count of attempt which will make the
function return a new value the next time it is called.
Parameters:
- self Instance
Returns:
-
Duration to wait in second
- socketio.backoff:reset (self)
-
Reset the attempt counter, meaning server did respond.
Parameters:
- self Instance