generic message dispatch object #355

Parent #1Owner #29Flags readSource hellcore/hellcore.db

Aliases: generic message dispatch object, dispatch

3 verbs · 12 properties · 1 children

Verbs

VerbSpecFlagsDefinerLines
parse_send_argsthis none thisrxd#35524
parse_receive_argsthis none thisrxd#35527
set_messages_in set_messages_outthis none thisrxd#3556

Properties

PropertyDefinerFlagsOwnerValue
messages_in#355r#29{}
messages_out#355r#29{}
aliases#1rc#29{"generic message dispatch object", "dispatch"}
description#1rc#29<clear>
object_size#1r#29{4143, 1298434676}
hidden_verbs#1rc#29<clear>
phelp_msg#1rc#29<clear>
weight#1rc#29<clear>
owner_verbs#1rc#29<clear>
plural_name#1rc#29<clear>
client_image#1rc#29<clear>
listening#1rc#29<clear>

Ancestry

Ancestors (nearest first): #1 root

Children: #354 generic MCP package

Call graph

calls n355_0 #355:parse_send_args n47_17 #47:assoc n355_0->n47_17 n47_62 #47:make_alist n355_0->n47_62 n355_1 #355:parse_receive_args n355_1->n47_17 n47_18 #47:iassoc n355_1->n47_18 n355_2 #355:set_messages_in n42_0 #42:controls n355_2->n42_0

Source

parse_send_args

Spec this none thisFlags rxdOwner #29Definer #355

Referenced by

Source

1"Usage:  :parse_send_args(msg, @posargs, @keywordargs)";
2"";
3"Transform a given message's arguments (mostly given positionally) into the correct form for MCP.  The cord type has an ordered list of argument keywords for all valid messages; these are matched with the arguments provided to produce an alist.  If more arguments are provided than keywords are available, then the remaining arguments should be {keyword, value} pairs.  This allows the passing of optional arguments and such.";
4"";
5"This verb returns an alist suitable for use with :client_notify().";
6"";
7"Examples:";
8"  .messages_out = {{\"edit\", {\"name\", \"text\"}}}";
9"  :parse_send_args(\"edit\", \"#123.foo\", {\"This is the first line.\"})";
10"    => {{\"name\", \"#123.foo\"}, {\"text\", {\"This is the first line.\"}}}";
11"  :parse_send_args(\"edit\", \"#123:foo\", {\"Hi!\"}, {\"type\", \"MOO-Code\"})";
12"    => {{\"name\", \"#123.foo\"}, {\"text\", {\"Hi!\"}}, {\"type\", \"MOO-Code\"}}";
13{msg, @rest} = args;
14a = $list_utils:assoc(msg, this.messages_out);
15if (!a)
16raise(E_INVARG, "Invalid message");
17endif
18keywords = a[2];
19lkeywords = length(keywords);
20lrest = length(rest);
21if (lrest < lkeywords)
22raise(E_ARGS, "Incorrect number of message arguments");
23endif
24return {@$list_utils:make_alist({keywords, rest[1..lkeywords]}), @rest[lkeywords + 1..$]};

parse_receive_args

Spec this none thisFlags rxdOwner #29Definer #355

Referenced by

Source

1"Usage:  :parse_receive_args(msg, alist)";
2"";
3"Transform a messages arguments from an alist into a mostly-positional list.  The cord type has an ordered list of argument keywords for all valid messages; these are used to construct an ordered list of the items from the alist that correspond to those keywords.  If there are items in the alist that do not match a known keyword, they will be appended to the positional list with keywords attached.";
4"";
5"Examples:";
6"  .messages_in = {{\"edit\", {\"name\", \"text\"}}}";
7"  :parse_receive_args({{\"name\", \"#123.foo\"}, {\"text\", {\"Hi!\"}}})";
8"    => {\"#123.foo\", \"Hi!\"}";
9"  :parse_receive_args({{\"name\", \"#123.foo\"}, {\"text\", {\"Hi!\"}}, {\"type\", \"MOO-Code\"}})";
10"    => {\"#123.foo\", \"Hi!\", {\"type\", \"MOO-Code\"}};";
11{msg, alist} = args;
12a = $list_utils:assoc(msg, this.messages_in);
13if (!a)
14"this should be caught upstream.";
15raise(E_INVARG, "Invalid cord message");
16endif
17ret = {};
18for keyword in (a[2])
19i = $list_utils:iassoc(keyword, alist);
20if (!i)
21"this too should be caught.";
22raise(E_INVARG, "Missing argument in cord message");
23endif
24ret = {@ret, alist[i][2]};
25alist = listdelete(alist, i);
26endfor
27return {@ret, @alist};

set_messages_in set_messages_out

Spec this none thisFlags rxdOwner #29Definer #355

Referenced by

none

Source

1"This is the standard :set_foo verb.  It allows the property to be set if called by this or called with adequate permissions (this's owner or wizardly).";
2if ((caller == this) || $perm_utils:controls(caller_perms(), this))
3return this.(verb[5..length(verb)]) = args[1];
4else
5return E_PERM;
6endif