Class PingPongService
- Namespace
- NLightning.Bolts.BOLT1.Services
- Assembly
- NLightning.Bolts.dll
Service for managing the ping pong protocol.
public class PingPongService : IPingPongService
- Inheritance
-
PingPongService
- Implements
- Inherited Members
Remarks
This class is used to manage the ping pong protocol.
Constructors
PingPongService(TimeSpan)
Service for managing the ping pong protocol.
public PingPongService(TimeSpan networkTimeout)
Parameters
networkTimeout
TimeSpanThe network timeout.
Remarks
This class is used to manage the ping pong protocol.
Methods
HandlePong(PongMessage)
Handles a pong message.
public void HandlePong(PongMessage pongMessage)
Parameters
pongMessage
PongMessageThe pong message.
Remarks
Handles a pong message. If the pong message has a different length than the ping message, DisconnectEvent is raised.
StartPingAsync(CancellationToken)
Starts the ping service.
public Task StartPingAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A task that represents the asynchronous operation.
Remarks
Ping messages are sent to the peer at random intervals ranging from 30 seconds to 5 minutes. If a pong message is not received within the network timeout, DisconnectEvent is raised.
Events
DisconnectEvent
Event that is raised when the pong is not received in time or the pong message is invalid.
public event EventHandler? DisconnectEvent
Event Type
PingMessageReadyEvent
Event that is raised when a ping message is ready to be sent.
public event EventHandler<PingMessage>? PingMessageReadyEvent