The base class for servers and clients More...
Inherits IDisposable.
Classes | |
class | BridgeState |
Public Member Functions | |
Peer (IceConfig config) | |
Create a new peer with the provided configuration More... | |
void | PrepareToConnect () |
Perform initial preparation. You can call this early to save time when actually connecting. More... | |
void | FinalizeConnection (IPEndPoint connectedEndPoint) |
Clean up unused routes after connection is established More... | |
IPAddress | MapToIPv4 (IPAddress address) |
void | EndSession (IPEndPoint connectedEndPoint) |
Completely end a session. More... | |
void | InitializeHosting (int hostPort, Action< string, ushort > onPrepared=null) |
Tell NobleConnect what port you are hosting on and get a relay address for clients to use to connect. More... | |
void | InitializeClient (IPEndPoint hostEndPoint, Action< IPEndPoint, IPEndPoint > onReadyToConnect) |
Use the hostEndPoint to establish a route to the host. When the route is established onReadyConnect will be called to tell the application where to connect. More... | |
void | CleanUpEverything () |
Revokes all permissions, channels, and allocations, destroys all bridges, and disposes of the ice controller More... | |
void | ConfigureStunController (Stun.Controller stunController) |
Configures a stun controller to pass data through to this peer More... | |
virtual void | Update () |
Keep everything running More... | |
void | SetLocalEndPoint (ushort port) |
Set the local end point that the application will connect from / listen on More... | |
void | HandleIncomingData (AttributeData data, IPEndPoint source, bool fromRelay) |
Pass the incoming data from the Turn server to the application More... | |
void | HandleOutgoingData (IAsyncResult result) |
Pass data from the application to the Turn server More... | |
virtual void | SendOutgoing (Bridge bridge, int numBytesToSend, PaddedBuffer buffer) |
Servers receive outgoing data on a socket and pass it to the Turn server as a Channel message. More... | |
Bridge | CreateBridge (CandidatePair selectedPair) |
Create a bridge between the provided remote address and the localEndPoint More... | |
void | DestroyBridge (Bridge bridge) |
Destroy a bridge and clean up More... | |
void | RevokePermissionsChannelsAndAllocation () |
Clean up all permissions, channels, and allocations More... | |
void | DestroyBridges () |
Destroy all bridges and close their associated sockets More... | |
void | Dispose () |
Dispose of all Bridges. Close all sockets. Stop all timers More... | |
Public Attributes | |
ConnectionType | latestConnectionType = ConnectionType.NONE |
The type of connection that was established. DIRECT, PUNCHTHROUGH, RELAY, or NONE More... | |
Protected Member Functions | |
virtual void | Dispose (bool disposing) |
Dispose of all Bridges. Close all sockets. Stop all timers. More... | |
Protected Attributes | |
Dictionary< IPEndPoint, Bridge > | bridgeByPeer = new Dictionary<IPEndPoint, Bridge>() |
This is used to look up which local socket to send out on depending on the peer it was received from More... | |
Dictionary< IPEndPoint, Bridge > | bridgeByClientEndPoint = new Dictionary<IPEndPoint, Bridge>() |
This is used to look up a Bridge by the local endpoint that the application connects to. More... | |
IPEndPoint | applicationEndPoint |
The local IPv4 end point that the application can receive from and send to. More... | |
IPEndPoint | applicationEndPointIPv6 |
The local IPv6 end point that the application can receive from and send to. More... | |
Properties | |
IPEndPoint | RelayEndPoint [get] |
This is the address that clients should connect to. It is assigned by the relay server. More... | |
The base class for servers and clients
The main purpose of this class is to create socket Bridges between the client / server applications and the Turn.Controller.
The application can not connect directly to the Turn server because the Turn.Controller is already connected using the local port that would be required to connect from.
To get around this Bridges are created between the application and the Turn.Controller.
When an application wishes to connect to a host over a relay it instead connects to a local bridge socket. This bridge socket receives outgoing data from the application and sends it to the relay over the Stun.Controller socket. Likewise, incoming application data on the Stun.Controller socket is sent to the application over the bridge socket.
For servers a bridge is created for each peer that wishes to connect. This way even though all of the data comes in from the Turn server, the application receives it as coming from a different local address for each client. In this way the relaying process is completely transparent to the application.
NobleConnect.Peer.Peer | ( | IceConfig | config | ) |
Create a new peer with the provided configuration
config |
void NobleConnect.Peer.CleanUpEverything | ( | ) |
Revokes all permissions, channels, and allocations, destroys all bridges, and disposes of the ice controller
void NobleConnect.Peer.ConfigureStunController | ( | Stun.Controller | stunController | ) |
Configures a stun controller to pass data through to this peer
stunController |
Bridge NobleConnect.Peer.CreateBridge | ( | CandidatePair | selectedPair | ) |
Create a bridge between the provided remote address and the localEndPoint
remoteIP | |
remotePort |
void NobleConnect.Peer.DestroyBridge | ( | Bridge | bridge | ) |
Destroy a bridge and clean up
bridge |
void NobleConnect.Peer.DestroyBridges | ( | ) |
Destroy all bridges and close their associated sockets
void NobleConnect.Peer.Dispose | ( | ) |
Dispose of all Bridges. Close all sockets. Stop all timers
|
protectedvirtual |
Dispose of all Bridges. Close all sockets. Stop all timers.
disposing |
void NobleConnect.Peer.EndSession | ( | IPEndPoint | connectedEndPoint | ) |
Completely end a session.
The permissions are revoked that were used to send the sip invite and answer Channels are revoked for all candidate pairs Binding refreshes are cancelled for all candidate pairs
connectedEndPoint |
void NobleConnect.Peer.FinalizeConnection | ( | IPEndPoint | connectedEndPoint | ) |
Clean up unused routes after connection is established
The permissions are revoked that were used to send the sip invite and answer Channels are revoked for all unused candidate pairs Binding refreshes are cancelled for all unused candidate pairs
connectedEndPoint |
void NobleConnect.Peer.HandleIncomingData | ( | AttributeData | data, |
IPEndPoint | source, | ||
bool | fromRelay | ||
) |
void NobleConnect.Peer.HandleOutgoingData | ( | IAsyncResult | result | ) |
Pass data from the application to the Turn server
This is called whenever the bridge socket receives data from the application. The data is immediately sent out to the relay server.
result |
void NobleConnect.Peer.InitializeClient | ( | IPEndPoint | hostEndPoint, |
Action< IPEndPoint, IPEndPoint > | onReadyToConnect | ||
) |
Use the hostEndPoint to establish a route to the host. When the route is established onReadyConnect will be called to tell the application where to connect.
hostEndPoint | The host's relay address. |
onReadyToConnect | An action to be called when a route is established |
void NobleConnect.Peer.InitializeHosting | ( | int | hostPort, |
Action< string, ushort > | onPrepared = null |
||
) |
Tell NobleConnect what port you are hosting on and get a relay address for clients to use to connect.
hostPort | The port the application is hosting on |
onPrepared | An action to be called when the relay address has been received |
IPAddress NobleConnect.Peer.MapToIPv4 | ( | IPAddress | address | ) |
void NobleConnect.Peer.PrepareToConnect | ( | ) |
Perform initial preparation. You can call this early to save time when actually connecting.
Gathers local and reflexive addresses and allocates relays.
void NobleConnect.Peer.RevokePermissionsChannelsAndAllocation | ( | ) |
Clean up all permissions, channels, and allocations
|
virtual |
Servers receive outgoing data on a socket and pass it to the Turn server as a Channel message.
bridge | |
numBytesToSend |
void NobleConnect.Peer.SetLocalEndPoint | ( | ushort | port | ) |
Set the local end point that the application will connect from / listen on
Bridges will send data coming from this end point out to the relay. Bridges will send data received from the relay to this end point.
port |
|
virtual |
Keep everything running
|
protected |
The local IPv4 end point that the application can receive from and send to.
This is set by hosts when starting hosting since the application port is usually known at that point. This is set by clients when they send the first outgoing package and the bridge socket receives it. Each bridge holds a socket that communicates with this end point. Data received from this end point will be sent out to the relay. Data received from the relay will be sent to this end point.
|
protected |
The local IPv6 end point that the application can receive from and send to.
This is set by hosts when starting hosting since the application port is usually known at that point. This is set by clients when they send the first outgoing package and the bridge socket receives it. Each bridge holds a socket that communicates with this end point. Data received from this end point will be sent out to the relay. Data received from the relay will be sent to this end point if it exists.
|
protected |
This is used to look up which local socket to send out on depending on the peer it was received from
ConnectionType NobleConnect.Peer.latestConnectionType = ConnectionType.NONE |
The type of connection that was established. DIRECT, PUNCHTHROUGH, RELAY, or NONE
|
get |
This is the address that clients should connect to. It is assigned by the relay server.
Note that this is not the host's actual IP address, but one assigned to the host by the relay server. When clients connect to this address, Noble Connect will find the best possible connection and use it. This means that the client may actually end up connecting to an address on the local network, or an address on the router, or an address on the relay. But you don't need to worry about any of that, it is all handled for you internally.