Hey
I finally did it, this taked a lot of time for me and i wanna share it, i hope this helps somebody. Sorry for my bad english.
openfl udpsocket example
Is this with haxe 3.3 nightly builds? As far as I know udp does not work with haxe 3.2.1… But last I tested openfl it does not work with haxe 3.3… Interested to know…
No, 3.3.0 official build.
What is the not working thing, OpenFl with Haxe 3.3.0 or UDPSocket? I am using OpenFl and Haxe with latest official builds. Maybe OpenFl wasn’t working with Haxe 3.3 when it released, but now they are working fine. Thanks for reply
Did you happen to manage for the server to get connections from a flash target ?
I was stuck at that.
UDPSocket isn’t available for flash target
How do you keep the thread alive?
Running my little example posted below, it runs the thread, logs the message at random and then proceeds to die. '
I’m targeting cpp.
import cpp.Lib;
import cpp.vm.Thread;
class Main
{
static function main()
{
trace('yoo');
Thread.create(thread);
}
static function thread(): Void
{
while (true) {
trace('asdasd');
}
}
}
Solved it by doing this for now
static function main()
{
var mutex = new Mutex();
Thread.create(thread.bind(mutex));
mutex.acquire();
}
static function thread(mutex: Mutex): Void
{
mutex.acquire();
while (true) {
trace('asdasd');
}
mutex.release();
}
while(true) is a infinite loop, so it could break the process. But listening port is freezing the process (that is why we are using threads for listening port, we dont want to freeze the main process) until some data comes. So infinite loop isn’t a problem if we are listening port in it, it continues only if there is a data.