1
votes

I'm working on an online game that will communicate with the backend using gRPC protocol. There are gRPC client libraries for iOS, Android and JavaScript.

The plan is to implement the game logic and rendering using Haxe, but networking using native code with gRPC. What's the recommended approach for that? I can see 2 options:

  1. Implement and build the game using Haxe in a way that it exposes some methods to native, e.g. a method to update game state using server data, and also accepts some callbacks from native, like a callback that is called every time the player makes an action that should be sent to the server. Then the callbacks and appropriate method calls can be implemented in the native projects generated by Haxe, using native tools like Xcode.

  2. Implement networking using native tools like Xcode and expose them to Haxe somehow. Then the game logic written in Haxe will call native methods and provide callbacks implemented in Haxe to native.

What's the recommended approach? It seems to me that the first approach might be simpler and have less potential issues. If you could also point me to some articles about that, it would be great, since I haven't found anything detailed enough.

1
Do you know about externs? - Michael
Yes I saw it. The problem is that it's very poorly documented. While the JS target has some documentation, C++, Java or Obj-C have very little or no at all. Do you know any better sources of info? - Michał Fronczyk
Please paste your try to implement one extern, also, you can see more practical example code.haxe.org/category/abstract-types/… - Michael
I'm not sure how abstract types are connected to interop. My question was not about a specific code and I don't have anything to paste. I was looking for a general advice - is it better to write a lot of externs and use them in Haxe, or is it better to expose Haxe code and use it from native languages. - Michał Fronczyk
In dynamic languages externs are preferred because haxe's type system and compile errors. In strict langs I think it is whatever is comfortable for you. - Michael

1 Answers

2
votes