本文整理汇总了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
}