Handling Network Events
How network data is sent to modules.
Commands sent between the client and server on the main game connection come in the form of (somewhat) human-readable lines. For example, a chat command from client to server, in C-string notation, would be
"\"blah blah blah\n"
to move northeast once.
(There are various resources on the web that catalogue Furcadia commands. For example, http://icerealm.quickfox.org/data/FTR/?)
When furnarchy intercepts a line from the client or server, it's sent to each modules' respective handler (on_onet() or on_inet(), depending on the direction). It's passed as a simple, null-terminated string with the trailing linefeed character discarded.
A line is sent to all the modules in 3 passes, giving you three opportunities to process the line. Each pass has different restrictions on what can be done with the line, which will likely dictate which pass of a particular message you choose to handle. The value of the rev
parameter of the on_inet()
handlers indicates the current pass.
The passes occur in the following order:
- The line is first sent to all modules during the
REV_DRAFT pass. The line cannot be modified during this pass, but it can be cancelled via f2_hideline(). This is an opportunity to see a line before modules have modified it.
- The line is sent a second time to all modules for the
REV_REVISING pass. The line may be modified via f2_reviseline() or cancelled via f2_hideline().
- The line is sent one final time to all modules for the
REV_FINAL pass. The line cannot be modified during this pass, but it can be cancelled via f2_hideline(). This is an opportunity to see the line after modules have modified it. For client->server lines, this what will actually be sent to the server, and for server->client lines, this is what will actually be received by the client.
Unlike Furnarchy 3, Furnarchy 2 doesn't parse network lines for you. This decision was made to un-clutter the API, as well as give you more freedom to mangle entire lines as you see fit. Parsing commands isn't always trivial, though, and to help you out, Furnarchy has an unofficial companion library, YIFFurc (http://www.heroinpuppy.com/forums/YaBB.cgi?num=1159017471/0#0
). YIFFurc is capable of decoding and encoding Furcadia network traffic with little hassle, among other things.