3. 커넥션과 오너십

- 서버커넥션과 클라이언트커넥션이 있음. 관계는 1:N

- 일반적으로 플레이어 컨트롤러는 넷커넥션을 소유하고 있음
- 언리얼 액터 클래스는
GetNetConnection()이란 간단한 메소드가 있음. Owner가 있으면 Owner의 넷커넥션을, 없으면 nullptr을 반환 - 플레이어 컨트롤러가 캐릭터를 Possess하면 Owner가 됨. 캐릭터가 소유한 모든 액터는 위 구조에 따라 플레이어 컨트롤러의 넷커넥션을 가져와 통신할 수 있게 됨
4. 액터의 역할과 커넥션 핸드셰이킹

리슨서버 클라이언트 로그인 시도 이후에:
PlayerController::BeginPlay()이후에ROLE_NONE→ROLE_AutonomousProxy로 역할 바뀜PlayerController::OnPossess()가 시작되면ROLE_SimulatedProxy였던AABCharacterPlayer의PossessedBy가 실행되면서AABCharacterPlayer의 소유자가PlyaerController_C_1로 바뀌며AutonomousProxy로 격상함

클라이언트 로그인 성공:
- 로컬의
PlayerController초기화 이후 네트워크 초기화하면(PostNetInit)ROLE_AutonomousProxy역할이 됨- 마찬가지로
AABGameState도 복제된 BeginPlay(OnRep_ReplicatedHasBegunPlay) 실행으로 서버의 게임상태를 시뮬레이팅하는 프록시(ROLE_SimulatedProxy)가 됨
- 마찬가지로

bool AController::IsLocalController() const { const ENetMode NetMode = GetNetMode(); if (NetMode == NM_Standalone) { // Not networked. return true; } if (NetMode == NM_Client && GetLocalRole() == ROLE_AutonomousProxy) { // Networked client in control. return true; } if (GetRemoteRole() != ROLE_AutonomousProxy && GetLocalRole() == ROLE_Authority) { // Local authority in control. return true; } return false; }서버에 있는 원격 플레이어의 PlayerController → LocalRole == ROLE_Authority → RemoteRole == ROLE_AutonomousProxy → IsLocalController() == false
서버가 직접 제어하는 Controller → LocalRole == ROLE_Authority → RemoteRole != ROLE_AutonomousProxy(원격 클라이언트에서 제어 못한다는 뜻. 나만 움직일 수 있음) → IsLocalController() == true
5. 액터 리플리케이션 기초
리플리케이션 방법은 두 가지가 있음
- Property Replication(속성 복제)
- Remote Procedure Call(함수 호출)