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

C++에서 Javascript 함수 호출을 하고 싶으나, CallJS에 대한 정의가 없습니다. #227

Open
kmu1205 opened this issue Oct 1, 2018 · 4 comments

Comments

@kmu1205
Copy link

@kmu1205 kmu1205 commented Oct 1, 2018

CallJS에 대한 정의가 없어서 C++에서 Javascript 함수 호출을 할 수 없는 상태입니다.
다른 방법이 있나요?

@kmu1205

This comment has been minimized.

Copy link
Author

@kmu1205 kmu1205 commented Oct 1, 2018

https://github.com/ncsoft/Unreal.js/wiki/Delegates

이 것을 찾아서 해보았는데, YourMember.Delegate의 변수 타입이 무엇인지 궁금합니다.
똑같이 FJavascriptFunction을 맴버변수로 두고 이로 했더니,
실행은 되지만 중지를 할 때 메모리 관련 크래쉬가 나는 상황입니다.

@crocuis

This comment has been minimized.

Copy link
Contributor

@crocuis crocuis commented Oct 2, 2018

C++에서 선언된 Delegate에 Javascript 쪽에서 Function을 등록 한 후 C++에서 Excute되면 Javascript에서 Callback이 호출됩니다.

@kmu1205

This comment has been minimized.

Copy link
Author

@kmu1205 kmu1205 commented Oct 2, 2018

C++에서 선언된 Delegate에 Javascript 쪽에서 Function을 등록 한 후 C++에서 Excute되면 Javascript에서 Callback이 호출됩니다.

혹시 간단하게 예시를 볼 수 있을까요?
https://github.com/ncsoft/Unreal.js/wiki/Delegates
링크로는 YourMember.Delegate에서 해당 변수 타입을 유추하기가 힘드네요.
부탁드리겠습니다.

@keicoon

This comment has been minimized.

Copy link
Contributor

@keicoon keicoon commented Oct 11, 2018

아래에 흐름에 따라 작성하겠습니다.

  1. c++에서 함수들 정의
void UYourClass::YourMethod(FJavascriptFunction Function)
{
  YourMember.Delegate = Function;
}
void UYourClass::YourEventHandler()
{
  YourMember.Delegate.Execute(); // call JS function
}
  1. js에서 delegate 등록을 호출
function A() {}
var some = new UYourClass();
some.YourMethod(A);
  1. c++에서 delegate 등록 확인 및 호출
void UYourClass::Tick()
{
   if( YourMember.Delegate is valid )
   {
      YourEventHandler();
   }
}

이렇게 시도해보시고 안되면 코멘트 부탁드립니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.