Class StunClient
STUN transactions over a datagram socket someone else reads: sends requests, retransmits them as RFC 8489 6.2.1 says, and completes them with the responses fed to Receive(ReadOnlySpan<byte>).
Inherited Members
Namespace: Uniform.Stun
Assembly: Uniform.Stun.dll
Syntax
public sealed class StunClient
Constructors
| Edit this page View SourceStunClient(DatagramSender)
STUN transactions over a datagram socket someone else reads: sends requests, retransmits them as RFC 8489 6.2.1 says, and completes them with the responses fed to Receive(ReadOnlySpan<byte>).
Declaration
public StunClient(DatagramSender send)
Parameters
| Type | Name | Description |
|---|---|---|
| DatagramSender | send | Sends a datagram. |
Properties
| Edit this page View SourceInitialTimeout
First retransmission timeout; it doubles after each.
Declaration
public TimeSpan InitialTimeout { get; init; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
MaxSends
Number of times a request is sent at most.
Declaration
public int MaxSends { get; init; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceIndicateAsync(StunMessage, IPEndPoint, CancellationToken)
Send an indication, which has no response.
Declaration
public ValueTask IndicateAsync(StunMessage indication, IPEndPoint to, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| StunMessage | indication | |
| IPEndPoint | to | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| ValueTask |
Receive(ReadOnlySpan<byte>)
Complete the transaction that datagram, a STUN message, answers; return whether one did.
Declaration
public bool Receive(ReadOnlySpan<byte> datagram)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | datagram |
Returns
| Type | Description |
|---|---|
| bool |
RequestAsync(StunMessage, IPEndPoint, byte[]?, bool, CancellationToken)
Send a request to server until a response comes; return it, or null when none came.
Declaration
public Task<StunMessage?> RequestAsync(StunMessage request, IPEndPoint server, byte[]? integrityKey = null, bool fingerprint = false, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| StunMessage | request | Request to send. |
| IPEndPoint | server | Address to send it to. |
| byte[] | integrityKey | Key of the MESSAGE-INTEGRITY attribute, when the request needs one. |
| bool | fingerprint | Whether to add a FINGERPRINT attribute, as ICE does. |
| CancellationToken | cancellationToken | Cancels the transaction. |
Returns
| Type | Description |
|---|---|
| Task<StunMessage> |