Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Jul 02, 2010 5:13 pm   

GMCP in CMUD
 
GMCP (Generic MUD Communication Protocol) is a MUD protocol. It's purpose was to take the ideas of the IRE ATCP protocol and make it generic enough for other MUDs to use. Some people call it ATCP2, but the protocol itself is much more generic than that. It basically just passes a set of messages between the client and server with the data in JSON string format. This is one of the reasons I started implementing the JSON stuff last month (the huge speed boost for tables and string lists was a nice bonus :)

In CMUD 3.22, only the communication protocol itself is implemented. CMUD does not yet do anything with the GMCP data and it does not yet tie the GMCP messages to the CMUD mapper. That will come in a later CMUD version (but soon).

For now, what you can do with GMCP is query the data and create GMCP triggers. GMCP defines "messages" within "packages". The general syntax is:

Package.Message JSON-Data

Subpackages are allowed with the format: Package.SubPackage.Message JSON-Data

The Packages and messages currently used in the test implementation on IRE MUDs can be found here: http://www.ironrealms.com/gmcp-doc
IMPORTANT NOTE: Because GMCP is currently in development, these messages can change at any time.

GMCP is enabled by default in CMUD. It can be disabled in the Preferences. The old "Simutronics" preference page has been renamed "Protocols" and a new tab for GMCP has been added. In that Preference screen you can list which packages you want the MUD to enable and send you data for. Each package is on a separate line with the Package.Subpackage name, followed by the numeric version of the package you want to enable. By default, CMUD enables:

core 1
char 1
room 1
comm 1

Simply edit this list of packages to include whatever GMCP data you want to receive.

When CMUD receives GMCP data, it gets stored in a single large internal table accessed via the %gmcp variable. The format of the %gmcp variable is:

%gmcp.package.message.key

For example, if you look at the IRE documentation, you'll see that the Room.Info package sends various information about the current room. To retrieve the current room Name, you would use:

#SHOW %gmcp.Room.Info.name

easy and simple.

You can also create GMCP triggers. Similar to MXP triggers, the Pattern for the trigger is tested against the Package.SubPackage.Message packet sent by the MUD. When a message matching your trigger is received, your trigger is fired and has access to the %gmcp array just like in any other script. However, the following variables are also set for use in your trigger:

%gmcp.module // main package name
%gmcp.package // actually the subpackage
%gmcp.message // the name of the message
%gmcp.data // the data received for this package as a database variable/string list
%gmcp.olddata // the previous data for this message
%0 // the raw string value received with the message. Should normally be a JSON string

If the data sent by the MUD does not parse as proper JSON, the raw string is stored within the %gmcp_errors.package.subpackage.message array. This can be used for trouble-shooting MUD GMCP implementations.

Keep in mind that the specific GMCP messages are typically MUD-specific. However, CMUD doesn't care what packages and what messages are sent. It just fires your GMCP triggers and stores all of the data in the %gmcp table. So it's very "Generic" as per the GMCP spec.

Finally, there is a special package.message called "core.hello" that you can create a GMCP trigger for. This is the initial message sent by CMUD to the MUD when the MUD first asks the client for GMCP support. As per the IRE spec linked above, CMUD normally sends the "core.hello" message with CMUD as the client name and the current CMUD version. CMUD then sends the list of desired packages (defined in your preferences screen) via the "core.supports.set" message.

If you are connecting to a MUD that needs a different handshake protocol, simply create a GMCP trigger for the core.hello message. Within this trigger you can use the #SENDGMCP command to send whatever data you want to the server. The format of the #SENDGMCP command is:

#SENDGMCP "Package.Message" @Table

where @Table is a normal CMUD database variable or string list with the data you want to send. This data will be converted to the correct JSON format needed by GMCP. For example, to emulate the current "core.hello" response, you would do this in your GMCP trigger:
Code:
$response = ""
#addkey $response client "CMUD"
#addkey $response version "3.22"
#SENDGMCP "core.hello" $response
$list = {core 1|char 1|room 1|comm 1}
#SENDGMCP "core.supports.set" $list

Note that if you want to get to the really raw level you can use the #SENDSB command to send the raw telnet data, but then you'll need to do your own JSON parsing, so it's recommended to just use #SENDGMCP instead.

This should be enough to get people started with GMCP. In future versions I'll start supporting specific MUD messages and get the mapper involved to improve the player experience, which was the original purpose of GMCP. I also expect to see other MUDs start using GMCP now that there are some test implementations of servers and clients to play with.

Please report any bugs or suggestions about the GMCP support to a SEPARATE POST.


Last edited by Zugg on Tue Sep 21, 2010 9:55 pm; edited 2 times in total
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Fri Jul 02, 2010 7:51 pm   
 
Ah ha this is awesome.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Fri Jul 02, 2010 8:23 pm   
 
How can we retrieve the Char.Vitals information? Right now it's just one big string.

I am currently using this trigger:

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger name="charVitals" type="GMCP" param="201" priority="2" regex="true" copy="yes">
    <pattern>^Char\.Vitals</pattern>
    <value>$gmcpData = %gmcp.Char.Vitals
#call %regex($gmcpData,"H:(\d+)/(\d+) M:(\d+)/(\d+) E:(\d+)/(\d+) W:(\d+)/(\d+) NL:(\d+)/100",health,healthMax,mana,manaMax,endur,endurMax,will,willMax,nextLevel)</value>
  </trigger>
</cmud>


Is there a better way to do this???
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Jul 02, 2010 10:00 pm   
 
I've asked IRE to break down the Char.Vitals into individual attributes and they are working on it. For now you have to parse it yourself as OldGuy shows.
Reply with quote
Aylorian
Beginner


Joined: 07 Jul 2008
Posts: 14
Location: Orlando

PostPosted: Tue Jul 27, 2010 11:40 pm   
 
We have started to implement GMCP in Aardwolf. A very early version of what we have so far can be seen on the Wiki page at http://www.aardwolf.com/wiki/index.php/Clients/GMCP.

There's a lot of messages to be added yet and some of the data may move between tags before this is all settled, but you can see that the basics are there and working.

There are also tools to see exactly what JSON the server is parsing and/or see a byte-level dump of the GMCP data received by the server. Feel free to use these if they have any value to you, they could be used for anything GMCP not just Aardwolf plugins.
Reply with quote
dbosst
Apprentice


Joined: 15 Jun 2010
Posts: 121

PostPosted: Fri Sep 03, 2010 1:35 am   
 
Zugg wrote:
I've asked IRE to break down the Char.Vitals into individual attributes and they are working on it. For now you have to parse it yourself as OldGuy shows.


I've noticed that this change has gone through at least in Achaea:
Code:

i  Achaea32 <<IAC><SB><201>Char.Vitals { "hp": "3223", "maxhp": "3223", "mp": "3460", "maxmp": "3460", "ep": "3963", "maxep": "15015", "wp": "16200", "maxwp": "16200", "nl": "28", "string": "H:3223/3223 M:3460/3460 E:3963/15015 W:16200/16200 NL:28/100 " }<IAC><SE><ESC>[4z<PROMPT><ESC>[32m3223h, <ESC>[37m<ESC>[32m3460m, <ESC>[37m<ESC>[1;33m3963e, <ESC>[0;37m<ESC>[32m16200w <ESC>[37mexkdb-<ESC>[4z</PROMPT><IAC><EOR>
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Tue Sep 21, 2010 9:55 pm   
 
This topic has been moved to the CMUD v3 Documentation.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net