Difference between revisions of "GMCP TinTin++ Tutorial"

From LegendMUD
Jump to navigation Jump to search
(Added TinTin++ GMCP tutorial)
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Enabling GMCP ==
 
== Enabling GMCP ==
In order to enable GMCP, you need to send a message to the MUD to let it know that the client supports it.
+
In order to enable [[GMCP]], you need to send a message to the MUD to let it know that the client supports it.
 
This is done by sending an <code>IAC DO GMCP</code> message when the MUD sends <code>IAC WILL GMCP</code>.
 
This is done by sending an <code>IAC DO GMCP</code> message when the MUD sends <code>IAC WILL GMCP</code>.
  
Line 24: Line 24:
  
 
== Receiving a GMCP message ==
 
== Receiving a GMCP message ==
Once GMCP is enabled, the MUD will begin broadcasting GMCP messages. To receive these messages, you must subscribe to GMCP events. This must be done for each package you want to receive messages for.
+
Once GMCP is enabled, the MUD will begin broadcasting GMCP messages.
 +
 
 +
There are two types of GMCP messages, broadcasts and requested messages.
 +
Broadcast messages will happen automatically, while requested messages will only be sent by the MUD if the client requests them.
 +
The full list of packages and their message types can be found [[GMCP Packages|here]].
 +
 
 +
To receive these messages, you must subscribe to GMCP events. This must be done for each package you want to receive messages for. A list of available packages can be found [[GMCP Packages|here]].
  
 
For example, if you wanted to receive the <code>room.info</code> messages, you would use the following script:
 
For example, if you wanted to receive the <code>room.info</code> messages, you would use the following script:

Latest revision as of 08:59, 7 January 2021

Enabling GMCP[edit]

In order to enable GMCP, you need to send a message to the MUD to let it know that the client supports it. This is done by sending an IAC DO GMCP message when the MUD sends IAC WILL GMCP.

In TinTin++, this is done via the following script:

#EVENT {IAC WILL GMCP}
{
    #SEND {\xFF\xFD\xC9};
}

Alternatively, it can be useful to store the hex codes as variables:

#VAR telnet[iac] \xFF;
#VAR telnet[do] \xFD;
#VAR telnet[sb] \xFA;
#VAR telnet[se] \xF0;
#VAR telnet[gmcp] \xC9;
#EVENT {IAC WILL GMCP}
{
    #SEND {$gmcp[iac]$telnet[do]$telnet[gmcp]};
}

The other scripts in this tutorial will use those variables. Note that anywhere these variables are used, you can replace them with the hex code instead.

Receiving a GMCP message[edit]

Once GMCP is enabled, the MUD will begin broadcasting GMCP messages.

There are two types of GMCP messages, broadcasts and requested messages. Broadcast messages will happen automatically, while requested messages will only be sent by the MUD if the client requests them. The full list of packages and their message types can be found here.

To receive these messages, you must subscribe to GMCP events. This must be done for each package you want to receive messages for. A list of available packages can be found here.

For example, if you wanted to receive the room.info messages, you would use the following script:

#EVENT {IAC SB GMCP room.info IAC SE}
{
    #VAR roominfo {%0};
}

The %0 parameter contains the data sent by the MUD. For convenience, it is recommended that you save this data in a #VARIABLE or #LOCAL.

Sending a GMCP message[edit]

The MUD will not broadcast every message that is available. Some messages must be manually requested. Additionally, some broadcasted messages can also be requested if you need to refresh the data before the MUD would broadcast again.

The following script can be used to send a request to the MUD:

#SEND {$telnet[iac]$telnet[sb]$telnet[gmcp]<package_name> <message_data>$telnet[iac]$telnet[se]};

It may be easier to create an alias to make this task easier. Aliases can later be used from the input line as well as from other scripts.

#ALIAS {gmcp %1 %*}
{
    #SEND {$telnet[iac]$telnet[sb]$telnet[gmcp]%1 %2$telnet[iac]$telnet[se];};
}

Usage: gmcp room.info {}

The following alias might also be useful if the package does not need any parameters provided:

#ALIAS {gmcp %1}
{
    #SEND {$telnet[iac]$telnet[sb]$telnet[gmcp]%1$telnet[iac]$telnet[se];};
}

Usage: gmcp room.info