3.4 仲介

ユーザとエージェントの間を取り持つエージェントについて説明します.教科書p.66 "3.4 人間とエージェントとの通信を支援する" の内容に相当します.

概要

%0 user user DB_access DB_access user->DB_access human-agent ODB_aomori ODB_aomori DB_access->ODB_aomori agent-agent

メッセージの流れ

useruserDB_accessDB_accessODB_aomoriODB_aomorifrom-userrequest-informationalt[success]informto-user[missing data]retrieve-failedsorry[other]sorrysorry

プログラム

ODB_aomori.groovy

(3.2節と同じ)

DB_access.groovy

class DB_access extends TAG {
    def loop(msg) {
        println msg
        if (msg._p=='from-user' && msg.whereis!=null) { // 所在地の問合せ
            Map m = request('ODB_aomori', [_p:'request-information', name:msg.whereis])
            reply(msg, [_p:'to-user', name:m.name, city:m.city])
        } else if (msg._p=='from-user' && msg.whattype!=null) { // 泉質の問合せ
            Map m = request('ODB_aomori', [_p:'request-information', name:msg.whattype])
            reply(msg, [_p:'to-user', name:m.name, type:m.type])
        } else {
            reply(msg, [_p:'sorry', msg:msg])
        }
    }
}

動作方法

課題

  1. 温泉の評価値を返すように機能拡張しましょう.