FactoryServerApi
1.0.0
Eine Implementierung der Dokumentationsdatei der zufriedenstellenden dedizierten Server -API sowohl UDP als auch HTTP.
Ist in generisches Host und vollständig asynchronisiert.
Der UDP -Einstiegspunkt IFactoryServerUdpClient , der aus einem Werk IFactoryServerUdpClientFactory erhalten wurde, ein Beispiel für die Verwendung
var builder = Host . CreateApplicationBuilder ( args ) ;
builder . AddFactoryServerServices ( ) ;
var app = builder . Build ( ) ;
var factoryUdpClientFactory = app . Services . GetRequiredService < IFactoryServerUdpClientFactory > ( ) ;
var factoryUdpClient = await factoryUdpClientFactory . BuildFactoryServerUdpServiceAsync ( "urlOrIPAddress" , port ) ;
factoryUdpClient . ServerStateReceived += FactoryUdpClient_ServerStateReceived ;
factoryUdpClient . ErrorOccurred += FactoryUdpClient_ErrorOccurred ;
var listenerCTS = new CancellationTokenSource ( ) ;
_ = factoryUdpClient . StartListeningAsync ( listenerCTS . Token ) ;
var pollTask = factoryUdpClient . PollServerStateAsync ( TimeSpan . FromMinutes ( 3 ) , TimeSpan . FromSeconds ( 10 ) , false , 1 , null ) ;
while ( ! pollTask . IsCompleted ) {
}
listenerCTS . Cancel ( ) ;
return 0 ;
private static void FactoryUdpClient_ErrorOccurred ( object ? sender , Exception e )
{
.. .
}
private static void FactoryUdpClient_ServerStateReceived ( object ? sender , FactoryServerStateResponse e )
{
var json = JsonSerializer . Serialize ( e ) ;
.. .
} Der HTTP -Einstiegspunkt IFactoryServerHttpService , ein Beispiel für die Verwendung
var builder = Host . CreateApplicationBuilder ( args ) ;
builder . AddFactoryServerServices ( ) ;
var app = builder . Build ( ) ;
var factoryServer = app . Services . GetRequiredService < IFactoryServerHttpService > ( ) ;
//Here in connection info you can set the AuthenticationToken provided for the login functions or third party tokens provided by server
var connectionInfo = new FactoryServerConnectionInfo ( "https_url" , port ) ;
var result = await factoryServer . HealthCheckAsync ( null , connectionInfo ) ;
string ? json = null ;
if ( result . Result is not null )
{
json = JsonSerializer . Serialize ( result . Result ) ;
}
else if ( result . Error is not null )
{
json = JsonSerializer . Serialize ( result . Error ) ;
}Ich bin neu darin und habe es als Hobby gemacht, um einen Server mit meinen Freunden aus der Ferne zu verwalten, sei nicht hart.
Fühlen Sie sich frei, Probleme für Fehler und Verbesserungen oder Gabel zu erstellen.