Dreamine.Communication.Sockets 1.0.2
Dreamine.Communication.Sockets 통신 기능과 관련 API를 제공합니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.Communication.Sockets.Servers.TcpServerTransport 클래스 참조sealed

더 자세히 ...

Dreamine.Communication.Sockets.Servers.TcpServerTransport에 대한 상속 다이어그램 :
Dreamine.Communication.Sockets.Servers.TcpServerTransport에 대한 협력 다이어그램:

클래스

class  TcpClientConnectionEntry

Public 멤버 함수

 TcpServerTransport (TcpServerTransportOptions options)
 TcpServerTransport (TcpServerTransportOptions options, IMessageProtocolAdapter protocolAdapter, IMessageFrameCodec frameCodec)
Task ConnectAsync (CancellationToken cancellationToken=default)
async Task DisconnectAsync (CancellationToken cancellationToken=default)
Task SendAsync (MessageEnvelope message, CancellationToken cancellationToken=default)
async Task SendAsync (TcpServerSendTargetMode targetMode, MessageEnvelope message, CancellationToken cancellationToken=default)
Task BroadcastAsync (MessageEnvelope message, CancellationToken cancellationToken=default)
async ValueTask DisposeAsync ()

속성

ConnectionState State [get]
TransportKind Kind [get]
int ConnectedClientCount [get]
TcpServerSendTargetMode SendTargetMode [get, set]

이벤트

EventHandler< MessageEnvelope >? MessageReceived
EventHandler< int >? ConnectedClientCountChanged

Private 멤버 함수

TcpClientConnectionEntry[] GetTargetClients (TcpServerSendTargetMode targetMode)
async Task SendToClientAsync (TcpClientConnectionEntry target, byte[] payload, CancellationToken cancellationToken)
async Task AcceptLoopAsync (CancellationToken cancellationToken)
async Task ReceiveLoopAsync (Guid clientId, TcpClient client, CancellationToken cancellationToken)
void CleanupListener ()
void CleanupClients ()
void RemoveClient (Guid clientId, TcpClient client)
void SetState (ConnectionState state)
void NotifyConnectedClientCountChanged ()

정적 Private 멤버 함수

static IPAddress ParseHost (string host)
static void ValidateOptions (TcpServerTransportOptions options)

Private 속성

readonly TcpServerTransportOptions _options
readonly IMessageProtocolAdapter _protocolAdapter
readonly IMessageFrameCodec _frameCodec
readonly ConcurrentDictionary< Guid, TcpClientConnectionEntry_clients = new()
TcpListener? _listener
CancellationTokenSource? _serverCts
Task? _acceptLoopTask
int _state = (int)ConnectionState.Disconnected

상세한 설명

여러 TCP 클라이언트의 연결, 수신 및 대상별 메시지 송신을 관리합니다.

여러 TCP 클라이언트의 연결, 수신 및 대상별 메시지 송신을 관리합니다.

TcpServerTransport.cs 파일의 31 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ TcpServerTransport() [1/2]

Dreamine.Communication.Sockets.Servers.TcpServerTransport.TcpServerTransport ( TcpServerTransportOptions options)
inline

기본 Dreamine JSON 프로토콜과 길이 접두사 프레임으로 TCP 서버를 초기화합니다.

매개변수
options수신 주소, 대기열, 버퍼 및 송신 대상 설정입니다.

TcpServerTransport.cs 파일의 123 번째 라인에서 정의되었습니다.

124 : this(
125 options,
126 new DreamineEnvelopeProtocolAdapter(),
127 new LengthPrefixedMessageFrameCodec())
128 {
129 }

◆ TcpServerTransport() [2/2]

Dreamine.Communication.Sockets.Servers.TcpServerTransport.TcpServerTransport ( TcpServerTransportOptions options,
IMessageProtocolAdapter protocolAdapter,
IMessageFrameCodec frameCodec )
inline

TCP 서버 설정과 사용자 지정 프로토콜 및 프레임 코덱으로 서버를 초기화합니다.

매개변수
options수신 주소, 대기열, 버퍼 및 송신 대상 설정입니다.
protocolAdapter메시지와 외부 페이로드를 변환할 어댑터입니다.
frameCodec클라이언트 스트림의 메시지 경계를 처리할 코덱입니다.
예외
ArgumentNullExceptionoptions , protocolAdapter 또는 frameCodecnull인 경우 발생합니다.

TcpServerTransport.cs 파일의 171 번째 라인에서 정의되었습니다.

175 {
176 _options = options ?? throw new ArgumentNullException(nameof(options));
177 _protocolAdapter = protocolAdapter ?? throw new ArgumentNullException(nameof(protocolAdapter));
178 _frameCodec = frameCodec ?? throw new ArgumentNullException(nameof(frameCodec));
179
180 ValidateOptions(_options);
181 }

다음을 참조함 : _frameCodec, _options, _protocolAdapter, ValidateOptions().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

멤버 함수 문서화

◆ AcceptLoopAsync()

async Task Dreamine.Communication.Sockets.Servers.TcpServerTransport.AcceptLoopAsync ( CancellationToken cancellationToken)
inlineprivate

TCP 클라이언트를 계속 수락하고 각 연결의 수신 루프를 시작합니다.

매개변수
cancellationToken수락 루프 종료 토큰입니다.
반환값
백그라운드 수락 루프 작업입니다.

TcpServerTransport.cs 파일의 702 번째 라인에서 정의되었습니다.

703 {
704 if (_listener is null)
705 {
706 return;
707 }
708
709 try
710 {
711 while (!cancellationToken.IsCancellationRequested &&
712 State == ConnectionState.Listening)
713 {
714 var client = await _listener.AcceptTcpClientAsync(cancellationToken)
715 .ConfigureAwait(false);
716
717 client.ReceiveBufferSize = _options.ReceiveBufferSize;
718 client.SendBufferSize = _options.SendBufferSize;
719
720 var clientId = Guid.NewGuid();
721 var entry = new TcpClientConnectionEntry(
722 clientId,
723 client,
724 DateTimeOffset.UtcNow);
725
726 _clients[clientId] = entry;
727 NotifyConnectedClientCountChanged();
728
729 _ = Task.Run(
730 () => ReceiveLoopAsync(clientId, client, cancellationToken),
731 cancellationToken);
732 }
733 }
734 catch (OperationCanceledException)
735 {
736 }
737 catch (ObjectDisposedException)
738 {
739 }
740 catch (SocketException)
741 {
742 if (!cancellationToken.IsCancellationRequested)
743 {
744 SetState(ConnectionState.Faulted);
745 CleanupListener();
746 CleanupClients();
747 }
748 }
749 catch (IOException)
750 {
751 if (!cancellationToken.IsCancellationRequested)
752 {
753 SetState(ConnectionState.Faulted);
754 CleanupListener();
755 CleanupClients();
756 }
757 }
758 catch
759 {
760 if (!cancellationToken.IsCancellationRequested)
761 {
762 SetState(ConnectionState.Faulted);
763 CleanupListener();
764 CleanupClients();
765 }
766 }
767 }

다음을 참조함 : _clients, _listener, _options, CleanupClients(), CleanupListener(), NotifyConnectedClientCountChanged(), ReceiveLoopAsync(), SetState(), State.

다음에 의해서 참조됨 : ConnectAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ BroadcastAsync()

Task Dreamine.Communication.Sockets.Servers.TcpServerTransport.BroadcastAsync ( MessageEnvelope message,
CancellationToken cancellationToken = default )
inline

연결된 모든 TCP 클라이언트에게 메시지를 병렬 전송합니다.

매개변수
message브로드캐스트할 메시지입니다.
cancellationToken브로드캐스트 취소 토큰입니다.
반환값
비동기 브로드캐스트 작업입니다.

TcpServerTransport.cs 파일의 532 번째 라인에서 정의되었습니다.

535 {
536 return SendAsync(TcpServerSendTargetMode.Broadcast, message, cancellationToken);
537 }

다음을 참조함 : SendAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ CleanupClients()

void Dreamine.Communication.Sockets.Servers.TcpServerTransport.CleanupClients ( )
inlineprivate

현재 연결된 모든 클라이언트를 제거하고 해제합니다.

TcpServerTransport.cs 파일의 883 번째 라인에서 정의되었습니다.

884 {
885 foreach (var pair in _clients.ToArray())
886 {
887 RemoveClient(pair.Key, pair.Value.Client);
888 }
889 }

다음을 참조함 : _clients, RemoveClient().

다음에 의해서 참조됨 : AcceptLoopAsync(), ConnectAsync(), DisconnectAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ CleanupListener()

void Dreamine.Communication.Sockets.Servers.TcpServerTransport.CleanupListener ( )
inlineprivate

정리 예외를 전파하지 않고 TCP Listener를 중지합니다.

TcpServerTransport.cs 파일의 861 번째 라인에서 정의되었습니다.

862 {
863 try
864 {
865 _listener?.Stop();
866 }
867 catch
868 {
869 // Ignore cleanup exceptions.
870 }
871
872 _listener = null;
873 }

다음을 참조함 : _listener.

다음에 의해서 참조됨 : AcceptLoopAsync(), ConnectAsync(), DisconnectAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ConnectAsync()

Task Dreamine.Communication.Sockets.Servers.TcpServerTransport.ConnectAsync ( CancellationToken cancellationToken = default)
inline

TCP Listener를 시작하고 백그라운드 클라이언트 수락 루프를 실행합니다.

매개변수
cancellationToken서버 및 수락 루프 수명과 연결할 취소 토큰입니다.
반환값
TCP 서버 시작 작업입니다.

TcpServerTransport.cs 파일의 271 번째 라인에서 정의되었습니다.

272 {
273 if (State is ConnectionState.Listening or ConnectionState.Connecting)
274 {
275 return Task.CompletedTask;
276 }
277
278 cancellationToken.ThrowIfCancellationRequested();
279
280 SetState(ConnectionState.Connecting);
281
282 try
283 {
284 CleanupListener();
285 CleanupClients();
286
287 var ipAddress = ParseHost(_options.Host);
288 _listener = new TcpListener(ipAddress, _options.Port);
289 _listener.Start(_options.Backlog);
290
291 _serverCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
292
293 SetState(ConnectionState.Listening);
294
295 _acceptLoopTask = Task.Run(
296 () => AcceptLoopAsync(_serverCts.Token),
297 _serverCts.Token);
298
299 return Task.CompletedTask;
300 }
301 catch
302 {
303 SetState(ConnectionState.Faulted);
304 CleanupListener();
305 CleanupClients();
306
307 _serverCts?.Dispose();
308 _serverCts = null;
309
310 throw;
311 }
312 }

다음을 참조함 : _acceptLoopTask, _listener, _options, _serverCts, AcceptLoopAsync(), CleanupClients(), CleanupListener(), ParseHost(), SetState(), State.

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ DisconnectAsync()

async Task Dreamine.Communication.Sockets.Servers.TcpServerTransport.DisconnectAsync ( CancellationToken cancellationToken = default)
inline

수락 루프와 Listener를 중지하고 연결된 모든 클라이언트를 해제합니다.

매개변수
cancellationToken정리 후 연결 해제 취소 여부를 확인하는 토큰입니다.
반환값
비동기 서버 종료 작업입니다.

TcpServerTransport.cs 파일의 338 번째 라인에서 정의되었습니다.

339 {
340 if (State == ConnectionState.Disconnected)
341 {
342 return;
343 }
344
345 SetState(ConnectionState.Disconnecting);
346
347 _serverCts?.Cancel();
348
349 CleanupClients();
350 CleanupListener();
351
352 if (_acceptLoopTask is not null)
353 {
354 try
355 {
356 await _acceptLoopTask.ConfigureAwait(false);
357 }
358 catch (OperationCanceledException)
359 {
360 }
361 catch (ObjectDisposedException)
362 {
363 }
364 catch (SocketException)
365 {
366 }
367 }
368
369 _serverCts?.Dispose();
370 _serverCts = null;
371 _acceptLoopTask = null;
372
373 cancellationToken.ThrowIfCancellationRequested();
374
375 SetState(ConnectionState.Disconnected);
376 }

다음을 참조함 : _acceptLoopTask, _serverCts, CleanupClients(), CleanupListener(), SetState(), State.

다음에 의해서 참조됨 : DisposeAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ DisposeAsync()

async ValueTask Dreamine.Communication.Sockets.Servers.TcpServerTransport.DisposeAsync ( )
inline

Listener, 수락 루프 및 클라이언트 연결을 비동기적으로 해제합니다.

반환값
비동기 리소스 해제 작업입니다.

TcpServerTransport.cs 파일의 595 번째 라인에서 정의되었습니다.

596 {
597 await DisconnectAsync().ConfigureAwait(false);
598 }

다음을 참조함 : DisconnectAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ GetTargetClients()

TcpClientConnectionEntry[] Dreamine.Communication.Sockets.Servers.TcpServerTransport.GetTargetClients ( TcpServerSendTargetMode targetMode)
inlineprivate

연결 시각과 대상 정책에 따라 송신 대상 클라이언트 스냅샷을 생성합니다.

매개변수
targetMode적용할 대상 선택 정책입니다.
반환값
선택된 클라이언트 연결 배열입니다.

TcpServerTransport.cs 파일의 564 번째 라인에서 정의되었습니다.

565 {
566 var entries = _clients.Values
567 .OrderBy(x => x.ConnectedAt)
568 .ToArray();
569
570 return targetMode switch
571 {
572 TcpServerSendTargetMode.Broadcast => entries,
573 TcpServerSendTargetMode.FirstClient => entries.Take(1).ToArray(),
574 TcpServerSendTargetMode.LastClient => entries.Reverse().Take(1).ToArray(),
575 _ => entries
576 };
577 }

다음을 참조함 : Dreamine.Communication.Sockets.Enums.Broadcast, Dreamine.Communication.Sockets.Enums.FirstClient, Dreamine.Communication.Sockets.Enums.LastClient.

다음에 의해서 참조됨 : SendAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ NotifyConnectedClientCountChanged()

void Dreamine.Communication.Sockets.Servers.TcpServerTransport.NotifyConnectedClientCountChanged ( )
inlineprivate

현재 연결 클라이언트 수로 변경 이벤트를 발생시킵니다.

TcpServerTransport.cs 파일의 964 번째 라인에서 정의되었습니다.

965 {
966 ConnectedClientCountChanged?.Invoke(this, ConnectedClientCount);
967 }

다음을 참조함 : ConnectedClientCount, ConnectedClientCountChanged.

다음에 의해서 참조됨 : AcceptLoopAsync(), RemoveClient().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ParseHost()

IPAddress Dreamine.Communication.Sockets.Servers.TcpServerTransport.ParseHost ( string host)
inlinestaticprivate

서버 바인딩 호스트 문자열을 IPv4 주소로 변환합니다.

매개변수
host변환할 호스트 문자열입니다.
반환값
바인딩에 사용할 IP 주소입니다.
예외
ArgumentException올바른 IP 주소가 아닌 경우 발생합니다.

TcpServerTransport.cs 파일의 1001 번째 라인에서 정의되었습니다.

1002 {
1003 if (host == "0.0.0.0")
1004 {
1005 return IPAddress.Any;
1006 }
1007
1008 if (host == "127.0.0.1" ||
1009 host.Equals("localhost", StringComparison.OrdinalIgnoreCase))
1010 {
1011 return IPAddress.Loopback;
1012 }
1013
1014 if (IPAddress.TryParse(host, out var ipAddress))
1015 {
1016 return ipAddress;
1017 }
1018
1019 throw new ArgumentException($"Invalid TCP server host: {host}", nameof(host));
1020 }

다음에 의해서 참조됨 : ConnectAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ReceiveLoopAsync()

async Task Dreamine.Communication.Sockets.Servers.TcpServerTransport.ReceiveLoopAsync ( Guid clientId,
TcpClient client,
CancellationToken cancellationToken )
inlineprivate

특정 클라이언트의 프레임을 계속 읽어 메시지 수신 이벤트를 발생시킵니다.

매개변수
clientId클라이언트 연결 식별자입니다.
client데이터를 읽을 TCP 클라이언트입니다.
cancellationToken수신 루프 종료 토큰입니다.
반환값
클라이언트 수신 루프 작업입니다.

TcpServerTransport.cs 파일의 809 번째 라인에서 정의되었습니다.

813 {
814 try
815 {
816 var stream = client.GetStream();
817
818 while (!cancellationToken.IsCancellationRequested &&
819 State == ConnectionState.Listening &&
820 client.Connected)
821 {
822 var payload = await _frameCodec.ReadFrameAsync(stream, cancellationToken)
823 .ConfigureAwait(false);
824
825 if (payload is null)
826 {
827 break;
828 }
829
830 var message = _protocolAdapter.Decode(payload);
831 MessageReceived?.Invoke(this, message);
832 }
833 }
834 catch (OperationCanceledException)
835 {
836 }
837 catch (ObjectDisposedException)
838 {
839 }
840 catch (SocketException)
841 {
842 }
843 catch
844 {
845 // 수신 루프 단위 예외는 해당 클라이언트 제거로 처리합니다.
846 }
847 finally
848 {
849 RemoveClient(clientId, client);
850 }
851 }

다음을 참조함 : _frameCodec, _protocolAdapter, MessageReceived, RemoveClient(), State.

다음에 의해서 참조됨 : AcceptLoopAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ RemoveClient()

void Dreamine.Communication.Sockets.Servers.TcpServerTransport.RemoveClient ( Guid clientId,
TcpClient client )
inlineprivate

연결 사전에서 클라이언트를 제거하고 소켓을 닫은 뒤 개수 변경을 알립니다.

매개변수
clientId제거할 연결 식별자입니다.
client닫고 해제할 TCP 클라이언트입니다.

TcpServerTransport.cs 파일의 915 번째 라인에서 정의되었습니다.

916 {
917 var removed = _clients.TryRemove(clientId, out _);
918
919 try
920 {
921 client.Close();
922 client.Dispose();
923 }
924 catch
925 {
926 // Ignore cleanup exceptions.
927 }
928
929 if (removed)
930 {
931 NotifyConnectedClientCountChanged();
932 }
933 }

다음을 참조함 : _clients, NotifyConnectedClientCountChanged().

다음에 의해서 참조됨 : CleanupClients(), ReceiveLoopAsync(), SendToClientAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ SendAsync() [1/2]

Task Dreamine.Communication.Sockets.Servers.TcpServerTransport.SendAsync ( MessageEnvelope message,
CancellationToken cancellationToken = default )
inline

구성된 기본 대상 정책에 따라 연결된 클라이언트에게 메시지를 전송합니다.

매개변수
message전송할 메시지입니다.
cancellationToken송신 취소 요청을 감시하는 토큰입니다.
반환값
비동기 대상별 송신 작업입니다.

TcpServerTransport.cs 파일의 410 번째 라인에서 정의되었습니다.

413 {
414 return SendAsync(SendTargetMode, message, cancellationToken);
415 }

다음을 참조함 : SendAsync(), SendTargetMode.

다음에 의해서 참조됨 : BroadcastAsync(), SendAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ SendAsync() [2/2]

async Task Dreamine.Communication.Sockets.Servers.TcpServerTransport.SendAsync ( TcpServerSendTargetMode targetMode,
MessageEnvelope message,
CancellationToken cancellationToken = default )
inline

지정한 대상 정책으로 선택한 클라이언트들에게 메시지를 병렬 전송합니다.

매개변수
targetMode클라이언트 선택 정책입니다.
message전송할 메시지입니다.
cancellationToken모든 클라이언트 송신 취소 토큰입니다.
반환값
선택된 모든 클라이언트의 병렬 송신 작업입니다.
예외
ArgumentNullException메시지가 null인 경우 발생합니다.
InvalidOperationException서버가 수신 대기 중이 아니거나 대상 클라이언트가 없는 경우 발생합니다.

TcpServerTransport.cs 파일의 473 번째 라인에서 정의되었습니다.

477 {
478 ArgumentNullException.ThrowIfNull(message);
479
480 if (State != ConnectionState.Listening)
481 {
482 throw new InvalidOperationException("TCP server is not listening.");
483 }
484
485 var payload = _protocolAdapter.Encode(message);
486 var targets = GetTargetClients(targetMode);
487
488 if (targets.Length == 0)
489 {
490 throw new InvalidOperationException("No TCP client is connected to the server.");
491 }
492
493 var sendTasks = targets
494 .Select(target => SendToClientAsync(target, payload, cancellationToken))
495 .ToArray();
496
497 await Task.WhenAll(sendTasks).ConfigureAwait(false);
498 }

다음을 참조함 : _protocolAdapter, GetTargetClients(), SendToClientAsync(), State.

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ SendToClientAsync()

async Task Dreamine.Communication.Sockets.Servers.TcpServerTransport.SendToClientAsync ( TcpClientConnectionEntry target,
byte[] payload,
CancellationToken cancellationToken )
inlineprivate

클라이언트별 잠금을 사용해 한 클라이언트에 프레임을 순차적으로 전송합니다.

매개변수
target대상 클라이언트 연결 정보입니다.
payload프레임으로 전송할 프로토콜 페이로드입니다.
cancellationToken잠금 대기와 송신 취소 토큰입니다.
반환값
단일 클라이언트 송신 작업입니다.

TcpServerTransport.cs 파일의 640 번째 라인에서 정의되었습니다.

644 {
645 cancellationToken.ThrowIfCancellationRequested();
646
647 if (!target.Client.Connected)
648 {
649 RemoveClient(target.ClientId, target.Client);
650 return;
651 }
652
653 await target.SendLock.WaitAsync(cancellationToken).ConfigureAwait(false);
654
655 try
656 {
657 if (!target.Client.Connected)
658 {
659 RemoveClient(target.ClientId, target.Client);
660 return;
661 }
662
663 var stream = target.Client.GetStream();
664
665 await _frameCodec.WriteFrameAsync(stream, payload, cancellationToken)
666 .ConfigureAwait(false);
667 }
668 catch
669 {
670 RemoveClient(target.ClientId, target.Client);
671 }
672 finally
673 {
674 target.SendLock.Release();
675 }
676 }

다음을 참조함 : _frameCodec, Dreamine.Communication.Sockets.Servers.TcpServerTransport.TcpClientConnectionEntry.Client, Dreamine.Communication.Sockets.Servers.TcpServerTransport.TcpClientConnectionEntry.ClientId, RemoveClient(), Dreamine.Communication.Sockets.Servers.TcpServerTransport.TcpClientConnectionEntry.SendLock.

다음에 의해서 참조됨 : SendAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ SetState()

void Dreamine.Communication.Sockets.Servers.TcpServerTransport.SetState ( ConnectionState state)
inlineprivate

원자적 연산으로 현재 서버 상태를 설정합니다.

매개변수
state저장할 새 상태입니다.

TcpServerTransport.cs 파일의 951 번째 라인에서 정의되었습니다.

952 {
953 Interlocked.Exchange(ref _state, (int)state);
954 }

다음을 참조함 : _state.

다음에 의해서 참조됨 : AcceptLoopAsync(), ConnectAsync(), DisconnectAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ValidateOptions()

void Dreamine.Communication.Sockets.Servers.TcpServerTransport.ValidateOptions ( TcpServerTransportOptions options)
inlinestaticprivate

TCP 서버 호스트, 포트, 대기열 및 버퍼 설정을 검증합니다.

매개변수
options검증할 TCP 서버 설정입니다.
예외
ArgumentException호스트가 비어 있는 경우 발생합니다.
ArgumentOutOfRangeException수치 설정이 허용 범위를 벗어난 경우 발생합니다.

TcpServerTransport.cs 파일의 1054 번째 라인에서 정의되었습니다.

1055 {
1056 ArgumentException.ThrowIfNullOrWhiteSpace(options.Host);
1057
1058 if (options.Port <= 0 || options.Port > 65535)
1059 {
1060 throw new ArgumentOutOfRangeException(nameof(options.Port));
1061 }
1062
1063 if (options.Backlog <= 0)
1064 {
1065 throw new ArgumentOutOfRangeException(nameof(options.Backlog));
1066 }
1067
1068 if (options.ReceiveBufferSize <= 0)
1069 {
1070 throw new ArgumentOutOfRangeException(nameof(options.ReceiveBufferSize));
1071 }
1072
1073 if (options.SendBufferSize <= 0)
1074 {
1075 throw new ArgumentOutOfRangeException(nameof(options.SendBufferSize));
1076 }
1077 }

다음을 참조함 : Dreamine.Communication.Sockets.Options.TcpServerTransportOptions.Backlog, Dreamine.Communication.Sockets.Options.TcpServerTransportOptions.Host, Dreamine.Communication.Sockets.Options.TcpServerTransportOptions.Port, Dreamine.Communication.Sockets.Options.TcpServerTransportOptions.ReceiveBufferSize, Dreamine.Communication.Sockets.Options.TcpServerTransportOptions.SendBufferSize.

다음에 의해서 참조됨 : TcpServerTransport().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ _acceptLoopTask

Task? Dreamine.Communication.Sockets.Servers.TcpServerTransport._acceptLoopTask
private

accept Loop Task 값을 보관합니다.

TcpServerTransport.cs 파일의 96 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ConnectAsync(), DisconnectAsync().

◆ _clients

readonly ConcurrentDictionary<Guid, TcpClientConnectionEntry> Dreamine.Communication.Sockets.Servers.TcpServerTransport._clients = new()
private

clients 값을 보관합니다.

TcpServerTransport.cs 파일의 68 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AcceptLoopAsync(), CleanupClients(), RemoveClient().

◆ _frameCodec

readonly IMessageFrameCodec Dreamine.Communication.Sockets.Servers.TcpServerTransport._frameCodec
private

frame Codec 값을 보관합니다.

TcpServerTransport.cs 파일의 59 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ReceiveLoopAsync(), SendToClientAsync(), TcpServerTransport().

◆ _listener

TcpListener? Dreamine.Communication.Sockets.Servers.TcpServerTransport._listener
private

listener 값을 보관합니다.

TcpServerTransport.cs 파일의 78 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AcceptLoopAsync(), CleanupListener(), ConnectAsync().

◆ _options

readonly TcpServerTransportOptions Dreamine.Communication.Sockets.Servers.TcpServerTransport._options
private

options 값을 보관합니다.

TcpServerTransport.cs 파일의 41 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AcceptLoopAsync(), ConnectAsync(), TcpServerTransport().

◆ _protocolAdapter

readonly IMessageProtocolAdapter Dreamine.Communication.Sockets.Servers.TcpServerTransport._protocolAdapter
private

protocol Adapter 값을 보관합니다.

TcpServerTransport.cs 파일의 50 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ReceiveLoopAsync(), SendAsync(), TcpServerTransport().

◆ _serverCts

CancellationTokenSource? Dreamine.Communication.Sockets.Servers.TcpServerTransport._serverCts
private

server Cts 값을 보관합니다.

TcpServerTransport.cs 파일의 87 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ConnectAsync(), DisconnectAsync().

◆ _state

int Dreamine.Communication.Sockets.Servers.TcpServerTransport._state = (int)ConnectionState.Disconnected
private

state 값을 보관합니다.

TcpServerTransport.cs 파일의 105 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : SetState().

속성 문서화

◆ ConnectedClientCount

int Dreamine.Communication.Sockets.Servers.TcpServerTransport.ConnectedClientCount
get

현재 서버에 연결된 TCP 클라이언트 수를 가져옵니다.

TcpServerTransport.cs 파일의 211 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : NotifyConnectedClientCountChanged().

◆ Kind

TransportKind Dreamine.Communication.Sockets.Servers.TcpServerTransport.Kind
get

TCP 전송 방식을 가져옵니다.

TcpServerTransport.cs 파일의 201 번째 라인에서 정의되었습니다.

◆ SendTargetMode

TcpServerSendTargetMode Dreamine.Communication.Sockets.Servers.TcpServerTransport.SendTargetMode
getset

기본 송신 작업에서 사용할 클라이언트 대상 정책을 가져오거나 설정합니다.

TcpServerTransport.cs 파일의 221 번째 라인에서 정의되었습니다.

222 {
223 get => _options.SendTargetMode;
224 set => _options.SendTargetMode = value;
225 }

다음에 의해서 참조됨 : SendAsync().

◆ State

ConnectionState Dreamine.Communication.Sockets.Servers.TcpServerTransport.State
get

스레드 안전하게 현재 서버 수신 대기 상태를 가져옵니다.

TcpServerTransport.cs 파일의 191 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AcceptLoopAsync(), ConnectAsync(), DisconnectAsync(), ReceiveLoopAsync(), SendAsync().

이벤트 문서화

◆ ConnectedClientCountChanged

EventHandler<int>? Dreamine.Communication.Sockets.Servers.TcpServerTransport.ConnectedClientCountChanged

서버에 연결된 클라이언트 수가 변경될 때 발생합니다.

TcpServerTransport.cs 파일의 245 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : NotifyConnectedClientCountChanged().

◆ MessageReceived

EventHandler<MessageEnvelope>? Dreamine.Communication.Sockets.Servers.TcpServerTransport.MessageReceived

클라이언트 프레임을 메시지로 디코딩했을 때 발생합니다.

TcpServerTransport.cs 파일의 235 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ReceiveLoopAsync().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: