Table of Contents

Class PingPongManager

Namespace
Alis.Core.Network
Assembly
Alis.dll

Ping Pong Manager used to facilitate ping pong WebSocket messages

public class PingPongManager : IPingPongManager

Inheritance

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

guid Guid
webSocket WebSocket

The web socket used to listen to ping messages and send pong messages

keepAliveInterval TimeSpan

The time between automatically sending ping messages. Set this to TimeSpan.Zero if you with to manually control sending ping messages.

cancellationToken CancellationToken

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 _cancellationToken

Field Value

CancellationToken

_guid

The guid

internal readonly Guid _guid

Field Value

Guid

_keepAliveInterval

The keep alive interval

internal readonly TimeSpan _keepAliveInterval

Field Value

TimeSpan

_pingSentTicks

The ping sent ticks

internal long _pingSentTicks

Field Value

long

_stopwatch

The stopwatch

internal readonly Stopwatch _stopwatch

Field Value

Stopwatch

_webSocket

The web socket

internal readonly WebSocketImplementation _webSocket

Field Value

WebSocketImplementation

Methods

HandleExpiredKeepAliveInterval()

Handles the expired keep alive interval

internal Task HandleExpiredKeepAliveInterval()

Returns

Task

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

e PongEventArgs

The

PingForever()

Pings the forever

internal Task PingForever()

Returns

Task

PingLoop()

Pings the loop

internal Task PingLoop()

Returns

Task

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

payload ArraySegment<byte>

The payload (must be 125 bytes of less)

cancellation CancellationToken

The cancellation token

Returns

Task

SendPing()

Sends the ping

internal Task SendPing()

Returns

Task

WebSocketImplPong(object, PongEventArgs)

Webs the socket impl pong using the specified sender

internal void WebSocketImplPong(object sender, PongEventArgs e)

Parameters

sender object

The sender

e PongEventArgs

The

Pong

Raised when a Pong frame is received

public event EventHandler<PongEventArgs> Pong

Event Type

EventHandler<PongEventArgs>