Changes

Jump to: navigation, search

IPDL/Five minute example

735 bytes added, 03:51, 21 July 2009
Put it all together
If you put your code in the <code>ipc/test-harness</code>, you can run it by invoking the test-harness binary. Navigate to your dist/bin directory and run
$ ./ipctestharness
If all goes well, you should see the output
[TestParent] in DoStuff()
[TestParent] world!
fly by eventually. Remember, the first and third messages are printed by the parent process, and the second is printed by the child process.
 
You can enable more detailed logging by setting the <code>MOZ_IPC_MESSAGE_LOG</code> environment variable in DEBUG builds. For this small example, you will only see something like the following
$ MOZ_IPC_MESSAGE_LOG=1 ./ipctestharness
// [...SNIP...]
[TestParent] in DoStuff()
[time:1248148008902152][TestProtocolParent] SendHello()
[time:1248148008902898][TestProtocolChild] RecvHello()
[TestChild] Hello,
[time:1248148008902939][TestProtocolChild] SendWorld()
[time:1248148008903080][TestProtocolParent] RecvWorld()
[TestParent] world!
Note, however, this code also logs the parameters and returned values of messages that have them (neither message in this little example do), so it can be a valuable debugging asset.
== Exercise: write a slightly less trivial protocol ==
Confirm
699
edits

Navigation menu