IAC SB GMCP MDSP.Report ["HEALTH", "HEALTH_MAX", "MANA", "MANA_MAX"] IAC SE
IAC SB GMCP MDSP.Values {"HEALTH": "10", "HEALTH_MAX": "30", "MANA": "17", "MANA_MAX", "42"} IAC SE
IAC SB GMCP MDSP.Report ["HEALTH", "HEALTH_MAX", "MANA", "MANA_MAX"] IAC SE
IAC SB GMCP MDSP.Values {"HEALTH": "10", "HEALTH_MAX": "30", "MANA": "17", "MANA_MAX", "42"} IAC SE
IAC SB GMCP 'MSDP { "REPORT" : "HEALTH", "HEALTH_MAX", "MANA", "MANA_MAX" }' IAC SEIt looks like a list of strings, which is exactly what I translated it to.
IAC SB GMCP 'MSDP { "REPORT" : "HEALTH", "HEALTH_MAX", "MANA", "MANA_MAX" }' IAC SEIt looks like a list of strings, which is exactly what I translated it to.
IAC SB GMCP 'MSDP { "REPORT" : "HEALTH" : "HEALTH_MAX" : "MANA" : "MANA_MAX" }' IAC SE
if (ch->desc->msdp_data)
{
char exits[MAX_INPUT_LENGTH];
int exit;
sprintf(exits, "%c", MSDP_OPEN);
for (exit = 0 ; exit < 6 ; exit++)
{
if (is_valid_exit(ch, ch->in_room, exit))
{
cat_sprintf(exits, "\001%s\002%d", dir_name_short[exit], ch->in_room->exit[exit]->to_room);
}
}
cat_sprintf(exits, "%c", MSDP_CLOSE);
msdp_update_var_instant(ch->desc, "ROOM", "%c\001%s\002%d\001%s\002%s\001%s\002%s\001%s\002%s\001%s\002%s%c",
MSDP_OPEN,
"VNUM", ch->in_room->vnum,
"NAME", ch->in_room->name,
"AREA", ch->in_room->area->name,
"TERRAIN", sector_table[ch->in_room->sector_type].sector_name,
"EXITS", exits,
MSDP_CLOSE);
}
{ "REPORT" : ["HEALTH" , "HEALTH_MAX" , "MANA" , "MANA_MAX"] }
import 'json'instead of spend an hour parsing some stupid text that i dont care much about.
{ "REPORT" : "HEALTH", "REPORT" : "HEALTH_MAX" , "REPORT" : "MANA" , "REPORT" : "MANA_MAX" }
descriptor_printf(d, "\001%s\002\003\001%s\002%s\001%s\002%s\001%s\002%s\004", "NESTED_ARRAYS", "A", "\005\002111\002222\002333\006", "B", "\005\002444\002555\002666\006", "C", "\005\002777\002888\002999\006");
descriptor_printf(d, "\001%s\002\005\002%s\002%s\002%s\006", "ARRAYED_ARRAYS", "\005\002A\002B\002C\006", "\005\002D\002E\002F\006", "\005\002G\002H\002I\006");
{ "REPORT" : "HEALTH", "REPORT" : "HEALTH_MAX" , "REPORT" : "MANA" , "REPORT" : "MANA_MAX" }
MSDP.Report ["HEALTH", "HEALTH_MAX", "MANA", "MANA_MAX"]
MSDP.Report "normal MSDP goes here, though you'd better use a JSON library so it can escape anything that needs to be escaped."
#define OBJECT_OPEN "\003"
#define OBJECT_CLOSE "\004"
#define ARRAY_OPEN "\005"
#define ARRAY_CLOSE "\006"
descriptor_printf(d,
"\001%s\002"
OBJECT_OPEN
"\001%s\002%s\001%s\002%s\001%s\002%s"
OBJECT_CLOSE,
"NESTED_ARRAYS",
"A", ARRAY_OPEN "\002111\002222\002333" ARRAY_CLOSE,
"B", ARRAY_OPEN "\002444\002555\002666" ARRAY_CLOSE,
"C", ARRAY_OPEN "\002777\002888\002999" ARRAY_CLOSE
);
MSDP.Report "normal MSDP goes here, though you'd better use a JSON library so it can escape anything that needs to be escaped."
I think server side easiest is to have the server listen for a single MSDP module. So to have variables reported the client would send:
IAC SB GMCP 'MSDP { "REPORT" : "HEALTH", "HEALTH_MAX", "MANA", "MANA_MAX" }' IAC SE
The server would translate this to MSDP data (which is fairly straightforward) and process it as is.
In response the server can either send a single MSDP module, or break down each variable into a module of its own. The downside of using a single module is that clients won't generate events for the nested variables, and users will have to copy the data to a safe location. It would look like:
IAC SB GMCP 'MSDP { "HEALTH" : "10", "HEALTH_MAX" : "30", "MANA" : "17", "MANA_MAX" : "42" }' IAC SE
While less efficient, the other alternative is sending each variable as it's own module, which would look like:
IAC SB GMCP 'MSDP.HEALTH "10"' IAC SE
IAC SB GMCP 'MSDP.HEALTH_MAX "30"' IAC SE
IAC SB GMCP 'MSDP.MANA "17"' IAC SE
IAC SB GMCP 'MSDP.MANA_MAX "42"' IAC SE
The second approach is probably the way to go as MCCP should compress most of the overhead.
Internally, it would be an option to use JSON, and have this translated to either MSDP or GMCP. This would fix readability issues, though not by a whole lot, and escaping problems would be introduced. For people who don't care (you can write MSDP arguments in octal notation) it's about as involved to translate MSDP to GMCP.
Feedback and suggestions welcome.