Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5차 - RPC #5

Open
pjc0247 opened this issue Feb 6, 2017 · 0 comments
Open

5차 - RPC #5

pjc0247 opened this issue Feb 6, 2017 · 0 comments

Comments

@pjc0247
Copy link
Owner

pjc0247 commented Feb 6, 2017

RPC

등록하기

int RPCSum(EzPlayer sender, int a, int b) {
    return a + b;
}


// 제너릭 인자 지정 해줘야함 (씨샵 버전 낮아서 이런걸로 추측)
// 리턴타입이 맨뒤
client.RegisterFunction<int, int, int>("sum", RPCSum);

// 또는 람다 함수 넣을 수 있음 (제너릭 자동)
client.RegisterFunction("sum2", (EzPlayer sender, int a, int b) => {
    return a + b;
});

호출하기

루트 유저한테 호출하기

var a = 10;
var b = 15;

client.RemoteCallToRootPlayer("sum", a, b,
    (RespondRemoteCall result) => {
        if (result.isSuccess) {
            result.Result; // 리턴값
        }
        else {
            result.Exception; // 에러
        }
    });

// 혹은 리턴값 무시하는 버전의 호출 가능
client.RemoteCallToRootPlayer("sum", a, b);

특정 플레이어한테 보내기

client.RemoteCall(player, "sum", a, b);

주의사항

  • RegisterFunction은 메인 스레드에서만 실행
  • 반환값, 전달값은 똒같이 Serialize 해야함 (기본형 제외)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant