How to use metadata for reflect function?

like here:

   @id(1)
public  static function test1(id:Int, callFun:TinyPlayer->Void)

    @id(2)
public  static function test2(id:Int, callFun:TinyPlayer->Void)

what I want to ask is are there any api to get test1 function from my custom metadata @id(1)

There is using haxe.rtti.Meta see Metadata - Haxe - The Cross-platform Toolkit.

edit: Oh you might have meant the other way, well you could add a build function to the class to look for them. Type Building - Haxe - The Cross-platform Toolkit
or you could go through everything in Context.onAfterTyping or Context.onGenerate but you won’t be able to do much at that point.

thanks ,but why my id is an array instead of int?

var xxx = Meta.getStatics(Test).test1.id; //=Array[0]

btw;

what I want is revert to get method name “test1” from @id(1)

Metas can have multiple parameters @hello(this, other, some) that’s why it is an array.

haxe.rtti.Meta won’t be able to do what you want, see my edit, but there’s nothing premade for that.

What are you trying to do?

from server socket ,get the mini data byte convert to function

from id=1 to convert to test1(id:Int, callFun:TinyPlayer->Void)

I 'm just remember there are a library name thinkbell? to do this,but I forgot how to do it as I did before?

You can find all tinkerbell libraries here https://haxetink.github.io/
Once you have found the one you need, using haxelib you can haxelib install <lib> and then add -lib <lib> to your hxml.

can you give a tutorial about GitHub - haxetink/tink_websocket: WebSocket in Haxe ?

it’s seem that can give something what I want.

@ibilon