HaXe Remote Socket trace function

From dis-Emi-A

Jump to: navigation, search


While developing flash programs the trace functionality can be quite helpful, though at times annoying as it writes into the main stage. To alleviate this problem the dhlib contains a SocketTrace which sends those traces over a socket to a remote listener (a console based listener is also included).

With the basic setup basically your trace statements get written to a console window rather than to the main screen.

It works in Flash9 and Neko targets.

Contents

Setup Client

To use the SocketTrace within your code, simply link to dhlib and call this function at any point in your code (during startup is most useful if you wish to send all trace's remotely)

system.SocketTrace.setup()

If the remote listener is not available the trace will revert to the local tracing method.

If you use ui.StageLayout this call will be made automatically if compiling in debug mode.

Setup Server

A simple listener is available and is suited for running in a console. Be sure to mark the console as UTF8 encoding to get proper unicode traces.

$DHLIB_ROOT/bin/trace_listener.sh

This will continue to listen on this port for any number of connections, though only one at a time can be handled.

Basic Server

The trace_listener.sh is a very basic script. If you have only the haxelib form of dhlib then you will need to get it separately.

trace_listener.sh

Non-Localhost Servers

If you are trying to connect from your server via a domain name other than localhost or 127.0.0.1 you will see that the sample server only ever prints <policy-file-request/> and you don't get traces going to the server.

This is part of the silly Adobe security system and will require you to serve a policy file from that machine. I use the simple server provided at [Adobe].

Then to invoke it you can use the python version with a policy file:

python Standalone/flashpolicyd.py --file=policy.xml"

You can setup a real policy file or for testing you can use this simple file.

<cross-domain-policy>
    <allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>
Personal tools