FactoryServerApi
1.0.0
การใช้งานไฟล์เอกสารของ API เซิร์ฟเวอร์เฉพาะที่น่าพอใจทั้ง UDP และ HTTP
ถูกรวมเข้ากับโฮสต์ทั่วไปและ Async อย่างเต็มที่
จุดเริ่มต้น UDP IFactoryServerUdpClient ที่ได้รับจากโรงงาน IFactoryServerUdpClientFactory ตัวอย่างของการใช้งาน
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 ) ;
.. .
} จุดเริ่มต้น HTTP IFactoryServerHttpService ตัวอย่างการใช้งาน
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 ) ;
}ฉันใหม่ในเรื่องนี้และฉันทำให้มันเป็นงานอดิเรกสำหรับการจัดการเซิร์ฟเวอร์จากระยะไกลกับเพื่อนของฉันอย่ารุนแรง
อย่าลังเลที่จะสร้างปัญหาสำหรับข้อบกพร่องและการปรับปรุงหรือส้อม