本文整理匯總了Golang中zombiezen/com/go/capnproto2/std/capnp/rpc.Message.Call方法的典型用法代碼示例。如果您正苦於以下問題:Golang Message.Call方法的具體用法?Golang Message.Call怎麽用?Golang Message.Call使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類zombiezen/com/go/capnproto2/std/capnp/rpc.Message
的用法示例。
在下文中一共展示了Message.Call方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleCallMessage
// handleCallMessage handles a received call message. It mutates the
// capability table of its parameter. The caller holds onto c.mu.
func (c *Conn) handleCallMessage(m rpccapnp.Message) error {
mcall, err := m.Call()
if err != nil {
return err
}
mt, err := mcall.Target()
if err != nil {
return err
}
if mt.Which() != rpccapnp.MessageTarget_Which_importedCap && mt.Which() != rpccapnp.MessageTarget_Which_promisedAnswer {
um := newUnimplementedMessage(nil, m)
return c.sendMessage(um)
}
mparams, err := mcall.Params()
if err != nil {
return err
}
if err := c.populateMessageCapTable(mparams); err == errUnimplemented {
um := newUnimplementedMessage(nil, m)
return c.sendMessage(um)
} else if err != nil {
c.abort(err)
return err
}
ctx, cancel := c.newContext()
id := answerID(mcall.QuestionId())
a := c.insertAnswer(id, cancel)
if a == nil {
// Question ID reused, error out.
c.abort(errQuestionReused)
return errQuestionReused
}
meth := capnp.Method{
InterfaceID: mcall.InterfaceId(),
MethodID: mcall.MethodId(),
}
paramContent, err := mparams.ContentPtr()
if err != nil {
return err
}
cl := &capnp.Call{
Ctx: ctx,
Method: meth,
Params: paramContent.Struct(),
}
if err := c.routeCallMessage(a, mt, cl); err != nil {
return a.reject(err)
}
return nil
}