‚Äč
GetConnection Functions

Functions

async Task< Socket > DistributedMatchEngine.MatchingEngine.GetTCPConnection (FindCloudletReply reply, AppPort appPort, int desiredPort=0, int timeoutMs=DEFAULT_GETCONNECTION_TIMEOUT_MS)
 
async Task< SslStream > DistributedMatchEngine.MatchingEngine.GetTCPTLSConnection (FindCloudletReply reply, AppPort appPort, int desiredPort=0, int timeoutMs=DEFAULT_GETCONNECTION_TIMEOUT_MS, bool allowSelfSignedCerts=false)
 
async Task< Socket > DistributedMatchEngine.MatchingEngine.GetUDPConnection (FindCloudletReply reply, AppPort appPort, int desiredPort=0, int timeoutMs=DEFAULT_GETCONNECTION_TIMEOUT_MS)
 
async Task< HttpClient > DistributedMatchEngine.MatchingEngine.GetHTTPClient (FindCloudletReply reply, AppPort appPort, int desiredPort=0, int timeoutMs=DEFAULT_GETCONNECTION_TIMEOUT_MS, string path="")
 
async Task< HttpClient > DistributedMatchEngine.MatchingEngine.GetHTTPSClient (FindCloudletReply reply, AppPort appPort, int desiredPort=0, int timeoutMs=DEFAULT_GETCONNECTION_TIMEOUT_MS, string path="")
 
async Task< ClientWebSocket > DistributedMatchEngine.MatchingEngine.GetWebsocketConnection (FindCloudletReply reply, AppPort appPort, int desiredPort=0, int timeoutMs=DEFAULT_GETCONNECTION_TIMEOUT_MS, string path="")
 
async Task< ClientWebSocket > DistributedMatchEngine.MatchingEngine.GetSecureWebsocketConnection (FindCloudletReply reply, AppPort appPort, int desiredPort=0, int timeoutMs=DEFAULT_GETCONNECTION_TIMEOUT_MS, string path="")
 

Detailed Description

GetConnection Workflow Example

var loc = await Util.GetLocationFromDevice();
FindCloudletReply reply = null;
try
{
reply = await me.RegisterAndFindCloudlet(dmeHost, MatchingEngine.defaultDmeRestPort,
orgName: orgName,
appName: appName,
appVersion: appVers,
loc: loc);
}
catch (DmeDnsException dde)
{
Console.WriteLine("Workflow DmeDnsException is " + dde);
}
catch (NotImplementedException nie)
{
Console.WriteLine("NotImplementedException is " + nie);
}
catch (RegisterClientException rce)
{
Console.WriteLine("Workflow RegisterClient is " + rce);
return;
}
Assert.ByVal(reply, Is.Not.Null);
Dictionary<int, AppPort> appPortsDict = me.GetTCPAppPorts(reply);
Assert.True(reply.status.Equals(FindCloudletReply.FindStatus.FIND_FOUND));
int public_port = reply.ports[0].public_port; // We happen to know it's the first one.
AppPort appPort = appPortsDict[public_port];
Assert.ByVal(appPort, Is.Not.Null);
try
{
Socket tcpConnection = await me.GetTCPConnection(reply, appPort, public_port, 5000);
Assert.ByVal(tcpConnection, Is.Not.Null);
tcpConnection.Close();
}
catch (GetConnectionException e)
{
Console.WriteLine("Workflow GetConnectionException is " + e.Message);
Assert.Fail("Workflow GetConnectionException is " + e.Message);
}
catch (Exception e)
{
Assert.Fail("workflow test exception " + e.Message);
}

Function Documentation

◆ GetHTTPClient()

async Task<HttpClient> DistributedMatchEngine.MatchingEngine.GetHTTPClient ( FindCloudletReply  reply,
AppPort  appPort,
int  desiredPort = 0,
int  timeoutMs = DEFAULT_GETCONNECTION_TIMEOUT_MS,
string  path = "" 
)

Returns an HTTP Client configured to send requests to application backend.

Parameters
reply(FindCloudletReply)
appPort(AppPort)
desiredPort(int): Optional
timeout(int): Optional
Returns
Task<HttpClient>

◆ GetHTTPSClient()

async Task<HttpClient> DistributedMatchEngine.MatchingEngine.GetHTTPSClient ( FindCloudletReply  reply,
AppPort  appPort,
int  desiredPort = 0,
int  timeoutMs = DEFAULT_GETCONNECTION_TIMEOUT_MS,
string  path = "" 
)

Returns an HTTPS Client configured to send requests to application backend.

Parameters
reply(FindCloudletReply)
appPort(AppPort)
desiredPort(int): Optional
timeout(int): Optional
Returns
Task<HttpClient>

◆ GetSecureWebsocketConnection()

async Task<ClientWebSocket> DistributedMatchEngine.MatchingEngine.GetSecureWebsocketConnection ( FindCloudletReply  reply,
AppPort  appPort,
int  desiredPort = 0,
int  timeoutMs = DEFAULT_GETCONNECTION_TIMEOUT_MS,
string  path = "" 
)

Returns a Secure Websocket Client configured to send requests to application backend.

Parameters
reply(FindCloudletReply)
appPort(AppPort)
desiredPort(int): Optional
timeout(int): Optional
Returns
Task<ClientWebSocket>

◆ GetTCPConnection()

async Task<Socket> DistributedMatchEngine.MatchingEngine.GetTCPConnection ( FindCloudletReply  reply,
AppPort  appPort,
int  desiredPort = 0,
int  timeoutMs = DEFAULT_GETCONNECTION_TIMEOUT_MS 
)

Get a TCP socket bound to the local cellular interface and connected to the application's backend server. If no exceptions thrown and object is not null, the socket is ready to send application data to backend.

Parameters
reply(FindCloudletReply)
appPort(AppPort)
desiredPort(int): Optional
timeout(int): Optional
Returns
Task<Socket>

◆ GetTCPTLSConnection()

async Task<SslStream> DistributedMatchEngine.MatchingEngine.GetTCPTLSConnection ( FindCloudletReply  reply,
AppPort  appPort,
int  desiredPort = 0,
int  timeoutMs = DEFAULT_GETCONNECTION_TIMEOUT_MS,
bool  allowSelfSignedCerts = false 
)

Returns a TCP socket with TLS running over it for secure data communication. Bound to local cellular interface and if no exceptions thrown and object is not null, the socket is ready to send application data to backend

Parameters
reply(FindCloudletReply)
appPort(AppPort)
desiredPort(int): Optional
timeout(int): Optional
Returns
Task<SslStream>

◆ GetUDPConnection()

async Task<Socket> DistributedMatchEngine.MatchingEngine.GetUDPConnection ( FindCloudletReply  reply,
AppPort  appPort,
int  desiredPort = 0,
int  timeoutMs = DEFAULT_GETCONNECTION_TIMEOUT_MS 
)

Get a UDP socket bound to the local cellular interface and connected to the application's backend server. If no exceptions thrown and object is not null, the socket is ready to send application data to backend.

Parameters
reply(FindCloudletReply)
appPort(AppPort)
desiredPort(int): Optional
timeout(int): Optional
Returns
Task<Socket>

◆ GetWebsocketConnection()

async Task<ClientWebSocket> DistributedMatchEngine.MatchingEngine.GetWebsocketConnection ( FindCloudletReply  reply,
AppPort  appPort,
int  desiredPort = 0,
int  timeoutMs = DEFAULT_GETCONNECTION_TIMEOUT_MS,
string  path = "" 
)

Returns an Websocket Client configured to send requests to application backend.

Parameters
reply(FindCloudletReply)
appPort(AppPort)
desiredPort(int): Optional
timeout(int): Optional
Returns
Task<ClientWebSocket>