本文整理匯總了Golang中zombiezen/com/go/capnproto2/std/capnp/rpc.Message.Disembargo方法的典型用法代碼示例。如果您正苦於以下問題:Golang Message.Disembargo方法的具體用法?Golang Message.Disembargo怎麽用?Golang Message.Disembargo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類zombiezen/com/go/capnproto2/std/capnp/rpc.Message
的用法示例。
在下文中一共展示了Message.Disembargo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleDisembargoMessage
func (c *Conn) handleDisembargoMessage(msg rpccapnp.Message) error {
d, err := msg.Disembargo()
if err != nil {
return err
}
dtarget, err := d.Target()
if err != nil {
return err
}
switch d.Context().Which() {
case rpccapnp.Disembargo_context_Which_senderLoopback:
id := embargoID(d.Context().SenderLoopback())
if dtarget.Which() != rpccapnp.MessageTarget_Which_promisedAnswer {
return errDisembargoNonImport
}
dpa, err := dtarget.PromisedAnswer()
if err != nil {
return err
}
aid := answerID(dpa.QuestionId())
a := c.answers[aid]
if a == nil {
return errDisembargoMissingAnswer
}
dtrans, err := dpa.Transform()
if err != nil {
return err
}
transform := promisedAnswerOpsToTransform(dtrans)
queued, err := a.queueDisembargo(transform, id, dtarget)
if err != nil {
return err
}
if !queued {
// There's nothing to embargo; everything's been delivered.
resp := newDisembargoMessage(nil, rpccapnp.Disembargo_context_Which_receiverLoopback, id)
rd, _ := resp.Disembargo()
if err := rd.SetTarget(dtarget); err != nil {
return err
}
c.sendMessage(resp)
}
case rpccapnp.Disembargo_context_Which_receiverLoopback:
id := embargoID(d.Context().ReceiverLoopback())
c.disembargo(id)
default:
um := newUnimplementedMessage(nil, msg)
c.sendMessage(um)
}
return nil
}