Corda作为传输层:读取数据

时间:2019-03-28 20:35:59

标签: corda

鉴于已建立的Corda节点网络,我希望在各方之间交换信息而无需访问Vault。

我的架构看起来像这样:
CLIPS (6.31 2/3/18) CLIPS> (deftemplate andprop (slot symbol1) (slot symbol2)) CLIPS> (deftemplate orprop (slot symbol1) (slot symbol2)) CLIPS> (deftemplate implies (multislot premise) (multislot implication)) CLIPS> (deftemplate sentence (multislot sent)) CLIPS> (defrule read-from-user => (printout t "Please enter a sentence: Use ~ for not and => for implies please " crlf) (bind ?response (readline)) (assert (sentence (sent (explode$ ?response))))) CLIPS> (defrule negative (sentence (sent "~" "(" "~" ?symbol ")")) => (printout t "HI " ?symbol crlf)) CLIPS> (run) Please enter a sentence: Use ~ for not and => for implies please ~(~P) HI P CLIPS> (reset) CLIPS> (run) Please enter a sentence: Use ~ for not and => for implies please ~(~XYZ) HI XYZ CLIPS> (facts) f-0 (initial-fact) f-1 (sentence (sent "~" "(" "~" XYZ ")")) For a total of 2 facts. CLIPS>

尽管发送数据非常简单,但我试图弄清 NodeB中出现什么内容时如何通知ClientB

1 个答案:

答案 0 :(得分:0)

您可以为此使用Flow Framework。

所以我假设您正在执行类似的操作,例如从NodeA与NodeB启动流会话,然后执行Send来发送一些数据?

val flowSession = initiateFlow(NodeB)
flowSession.send(someData)

在NodeB上,响应流将接收此数据,并且您可以使用Java领域内的任何内容来通知ClientB。如果要通过触发RPC通知客户端,则可以执行此操作。

@InitiatedBy(Initiator::class)
class Responder(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
    @Suspendable
    override fun call() {
        val yourData = counterpartySession.receive<String>().unwrap { it }

        //Some code to alert Client B
    }
}