Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The did-sov-SLfEi9esrjzybysFxQZbfq ruleset handles an incoming basicmessage with the rule shown below. The rule selects (line 12) on the same event, sovrin:basicmessage_message, but only when (line 13) the content of the message is a Map which has a key “@type” whose value matches the mturi pattern (as it line 4) (this is defined in the Tic Tax Tac Toe protocol).

Code Block
breakoutModewide
ruleset did-sov-SLfEi9esrjzybysFxQZbfq {
  ...
  global {
      mturi = re#did:sov:SLfEi9esrjzybysFxQZbfq;spec/tictactoe/1.0/([A-Za-z0-9_.-]+)#
      ...
  }
...
//
// eavesdrop incoming agent basicmessages for one of interest
//
  rule eavesdrop_basicmessage {
    select when sovrin basicmessage_message
      where event:attr("message"){["content","@type"]}.match(mturi)
    pre {
      content = event:attr("message"){"content"}
      event_type = content{"@type"}.extract(mturi).head()
      conn = event_type => agent:connections(){event:attr("sender_key")}
                         | null
    }
    if event_type && conn then noop()
    fired {
      ent:opponent := conn{"label"}
      ent:their_vk := conn{"their_vk"}
      ent:my_did := conn{"my_did"}
      raise tictactoe event event_type attributes content
    }
  }

...