本文整理匯總了Golang中github.com/project-iris/iris/proto.Message.Decrypt方法的典型用法代碼示例。如果您正苦於以下問題:Golang Message.Decrypt方法的具體用法?Golang Message.Decrypt怎麽用?Golang Message.Decrypt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/project-iris/iris/proto.Message
的用法示例。
在下文中一共展示了Message.Decrypt方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleBalance
// Handles the load balancing event of a topio.
func (o *Overlay) handleBalance(msg *proto.Message, topicId *big.Int, prevHop *big.Int) (bool, error) {
sid := topicId.String()
// Fetch the topic or report not found
o.lock.RLock()
top, ok := o.topics[sid]
topName := o.names[sid]
o.lock.RUnlock()
if !ok {
// No error, but not handled either
return false, nil
}
// Fetch the recipient and either forward or deliver
node, err := top.Balance(prevHop)
if err != nil {
return true, err
}
// If it's a remote node, forward
if node.Cmp(o.pastry.Self()) != 0 {
o.fwdBalance(node, msg)
return true, nil
}
// Remove all carrier headers and decrypt
head := msg.Head.Meta.(*header)
msg.Head.Meta = head.Meta
if err := msg.Decrypt(); err != nil {
return true, err
}
// Deliver to the application on the specific topic
o.app.HandleBalance(head.Sender, topName, msg)
return true, nil
}
示例2: handleDirect
// Handles the receiving of a direct message and delivers the contents upstream.
func (o *Overlay) handleDirect(msg *proto.Message) error {
// Remove all scribe headers and decrypt contents
head := msg.Head.Meta.(*header)
msg.Head.Meta = head.Meta
if err := msg.Decrypt(); err != nil {
return err
}
// Deliver the message upstream
o.app.HandleDirect(head.Sender, msg)
return nil
}