Class PingPongManager
- Namespace
- Alis.Core.Network
- Assembly
- Alis.dll
Ping Pong Manager used to facilitate ping pong WebSocket messages
public class PingPongManager : IPingPongManagerInheritance
Implements
Inherited Members
Constructors
PingPongManager(Guid, WebSocket, TimeSpan, CancellationToken)
Initialises a new instance of the PingPongManager to facilitate ping pong WebSocket messages. If you are manually creating an instance of this class then it is advisable to set keepAliveInterval to TimeSpan.Zero when you create the WebSocket instance (using a factory) otherwise you may be automatically be sending duplicate Ping messages (see keepAliveInterval below)
public PingPongManager(Guid guid, WebSocket webSocket, TimeSpan keepAliveInterval, CancellationToken cancellationToken)Parameters
guidGuidwebSocketWebSocket-
The web socket used to listen to ping messages and send pong messages
keepAliveIntervalTimeSpan-
The time between automatically sending ping messages. Set this to TimeSpan.Zero if you with to manually control sending ping messages.
cancellationTokenCancellationToken-
The token used to cancel a pending ping send AND the automatic sending of ping messages if keepAliveInterval is positive
Fields
_cancellationToken
The cancellation token
internal readonly CancellationToken _cancellationTokenField Value
_guid
The guid
internal readonly Guid _guidField Value
_keepAliveInterval
The keep alive interval
internal readonly TimeSpan _keepAliveIntervalField Value
_pingSentTicks
The ping sent ticks
internal long _pingSentTicksField Value
_stopwatch
The stopwatch
internal readonly Stopwatch _stopwatchField Value
_webSocket
The web socket
internal readonly WebSocketImplementation _webSocketField Value
Methods
HandleExpiredKeepAliveInterval()
Handles the expired keep alive interval
internal Task HandleExpiredKeepAliveInterval()Returns
LogPingPongManagerEnd()
Logs the ping pong manager end
internal void LogPingPongManagerEnd()LogPingPongManagerStart()
Logs the ping pong manager start
internal void LogPingPongManagerStart()OnPong(PongEventArgs)
Ons the pong using the specified e
protected virtual void OnPong(PongEventArgs e)Parameters
ePongEventArgs-
The
PingForever()
Pings the forever
internal Task PingForever()Returns
PingLoop()
Pings the loop
internal Task PingLoop()Returns
PingSentTicksExist()
Describes whether this instance ping sent ticks exist
internal bool PingSentTicksExist()Returns
- bool
-
The bool
SendPing(ArraySegment<byte>, CancellationToken)
Sends a ping frame
public Task SendPing(ArraySegment<byte> payload, CancellationToken cancellation)Parameters
payloadArraySegment<byte>-
The payload (must be 125 bytes of less)
cancellationCancellationToken-
The cancellation token
Returns
SendPing()
Sends the ping
internal Task SendPing()Returns
WebSocketImplPong(object, PongEventArgs)
Webs the socket impl pong using the specified sender
internal void WebSocketImplPong(object sender, PongEventArgs e)Parameters
senderobject-
The sender
ePongEventArgs-
The
Pong
Raised when a Pong frame is received
public event EventHandler<PongEventArgs> Pong