generic message dispatch object #355
Aliases: generic message dispatch object, dispatch
3 verbs · 12 properties · 1 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
parse_send_args | this none this | rxd | #355 | 24 |
parse_receive_args | this none this | rxd | #355 | 27 |
set_messages_in set_messages_out | this none this | rxd | #355 | 6 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
messages_in | #355 | r | #29 | {} |
messages_out | #355 | r | #29 | {} |
aliases | #1 | rc | #29 | {"generic message dispatch object", "dispatch"} |
description | #1 | rc | #29 | <clear> |
object_size | #1 | r | #29 | {4143, 1298434676} |
hidden_verbs | #1 | rc | #29 | <clear> |
phelp_msg | #1 | rc | #29 | <clear> |
weight | #1 | rc | #29 | <clear> |
owner_verbs | #1 | rc | #29 | <clear> |
plural_name | #1 | rc | #29 | <clear> |
client_image | #1 | rc | #29 | <clear> |
listening | #1 | rc | #29 | <clear> |
Ancestry
Ancestors (nearest first): #1 root
Children: #354 generic MCP package
Call graph
Source
parse_send_args
Referenced by
- #354:send_* line 4:
this:parse_send_args
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
Referenced by
- #354:dispatch line 6:
this:parse_receive_args
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
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