COMMUNITY

Hashlink: calling functions from one Haxe/C in other Haxe/C

haxe-hl

(Flashultra) #1

Hashlink: calling functions from one Haxe/C in other Haxe/C
Hi,
I have two haxe projects - “server” and “extension” and both will be compile to C code using Hashlink.
My goal is after some event occur in “server” project to call function from “extension” project. Is that feasible , because both will be compile to binary code ( via C) and in some aspect extension will be something like external library for “server”?
Here is simple example:

class Server {
    static function main() 
    {
	// 1. Scannig directory "extensions" and find classes extends BaseExtension 
        // 2. Create classes and put in Array
        // 3. Wating for event "receive message" and when occur, call method onMsgReceive for all classes in Array
    }
}

class Extension  extends BaseExtension {
  public function onMsgReceive (data:Dynamic):Void {
   // Do something with data 
 }
}

So my main goal is to have one project which will be a socket server and it will receive messages and everyone could create separate project , extending class BaseExtension , and can add specific logic for his project. Server will call code in extension project when events comes.
One solution is to have one project ( not server and extension ) ,but in that case if you want to write simple extension you should compile server code too.