FactoryServerApi
1.0.0
만족스러운 전용 서버 API (UDP 및 HTTP)의 문서 파일 구현.
일반 호스트 및 완전 비동기와 통합됩니다.
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 ) ;
}나는 이것에 새롭고, 친구들과 원격으로 서버를 관리하는 취미로 만들었습니다.
버그 및 개선 사항 또는 포크에 대한 문제를 자유롭게 만들 수 있습니다.