Guns Protocol
From NarcWiki
The Guns protocol is based on the EDIFACT protocol, made slightly more human-readable by replacing the few key characters (space as element separator, comma as list separator, line feed as "segment" separator, backslash as escape character).
The reason for using it is it's a nice, low-bandwidth protocol with sufficient freedom to be useful while remaining sufficiently simple to be quickly comprehensible to a reader (a.k.a. tired programmer debugging).
Extension Note: An extension to the simple protocol is "long data", used only by the lobby protocol: some commands may require a lot of data, which can't be easily transmitted as an argument (element/list) to a normal command (segment). In this case, the server will notify the client that it's entering "long data" mode, and that it will process everything up to the next long data separator ("\n.\n", aka ". on a line by itself") as a single unit. At the end of a long data unit, the server automatically resumes normal operation.
Contents |
Summary/Overview
Messages are strings terminated by \n, containing one or more space-separated elements, some of which can be comma-separated lists.
The first element of a message is always its three-letter (case-insensitive) type identifier, which determines what other elements may be present in the message.
Implementation detail: messages can and should be bunched together for sending in a single datagram, when possible. When reading a datagram, expect multiple \n-separated messages.
Reading message formats:
TLA <required parameter> [optional parameter]
Common messages
These are used in both lobby and battle protocols, as core utility messages:
Error
ERR <error-id> [error message]
Sent by a server or client to inform the other party there's a problem. Mostly only useful in S2C, but could be encountered in the opposite as well.
| Error ID | Message |
|---|---|
| 99 | Argument error: too few/many arguments. |
| 100 | Battle authentication failure |
Warning
WAR <warning-id> [warning message]
Sent by client or server to inform the other party of changes in normal handling that are not problems. Most notably, warns of entering "long data" mode.
| Warning ID | Message |
|---|---|
| 1 | Entering long data mode, end with "." by itself on a line. |
| 2 | Exited long data mode. |