UDN
Search public documentation:

ReplicationPatternClientToServerRPCKR
English Translation
日本語訳
中国翻译

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 홈 > 네트워킹과 리플리케이션 > 클라이언트 투 서버 리모트 프로시저 콜 패턴

클라이언트 투 서버 리모트 프로시저 콜 패턴


문서 변경내역: James Tan 작성. 홍성진 번역.

개요


클라이언트 투 서버 리모트 프로시저 콜 은 클라이언트 데이터를 서버로 전송하고자 할 때 사용됩니다. 클라이언트 데이터 자체로는 서버에 혼자 리플리케이트되지 않습니다. 서버가 게임 상태 안에 모든 클래스 변수 제어권을 유지하기 위함입니다. 클라이언트가 클라이언트 투 서버 리모트 프로시저 콜 을 사용하도록 함으로써 서버는 항상 들어오는 클라이언트 데이터를 가로챌 수 있는 것입니다.

Player Controller 클래스


플레이어 콘트롤러 는 클라이언트와 서버간 통신에 있어 다리 중 하나의 역할을 합니다. 각 플레이어는 자체 플레이어 콘트롤러 를 소유합니다. 여기서는 오로지 데모 목적으로 Reliable 을 사용했습니다. Reliable 은 리모트 프로시저 콜과 그 파라미터를 서버에 꼭 전달해야할 때 사용합니다. Unreliable 은 리모트 프로시저 콜과 그 파라미터가 대역폭 포화 상태에 따라 짤리거나 버려져도 상관없을 경우에 사용합니다.

CTSRPC_PlayerController.uc
class CTSRPC_PlayerController extends PlayerController;

/**
 * 클라이언트가 텍스트를 서버로 전송할 수 있도록 하는 exec 함수입니다.
 *
 * 네트워크: 클라이언트
 */
exec function SendTextToServer(String TextToSend)
{
  // 플레이어 콘트롤러의 롤이 authoritive 가 아니고
  // 텍스트가 비어있지 않은 경우
  if (Role < Role_Authority && TextToSend != "")
  {
    `Log(Self$":: Client wants to send '"$TextToSend$"' to the server.");
    ServerReceiveText(TextToSend);
  }
}

/**
 * 클라이언트에서 텍스트를 받는 server 함수
 *
 * 네트워크: 데디케이티드/리슨 서버
 */
reliable server function ServerReceiveText(String ReceivedText)
{
  // 플레이어 콘트롤러의 롤이 authoritive 이고
  // 텍스트는 비어있지 않은 경우
  if (Role == Role_Authority && ReceivedText != "")
  {
    `Log(Self$":: Server received text, '"$ReceivedText$"'.");
  }
}

defaultproperties
{
}

Game Info 클래스


GameInfo 는 서버에만 존재합니다. 이 패턴에서는 연결된 플레이어에 올바른 PlayerController 를 스폰하는 데에만 사용되었습니다.

CTSRPC_GameInfo.uc
class CTSRPC_GameInfo extends GameInfo;

defaultproperties
{
  PlayerControllerClass=class'CTSRPC_PlayerController'
}

테스팅


클라이언트에서 SendTextToServer 가 "My message to the server. Road house!" 파라미터로 실행되었습니다.

CTSRPC_ClientConsoleWindow.jpg

서버에서 리모트 프로시저 콜 'ServerReceiveText' 가 "My message to the server. Road house!" 파라미터와 함께 수신되었습니다.

CTSRPC_ServerConsoleWindow.jpg

내려받기