本文整理匯總了Golang中github.com/marcosQuesada/mesh/peer.NodePeer.State方法的典型用法代碼示例。如果您正苦於以下問題:Golang NodePeer.State方法的具體用法?Golang NodePeer.State怎麽用?Golang NodePeer.State使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/marcosQuesada/mesh/peer.NodePeer
的用法示例。
在下文中一共展示了NodePeer.State方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: HandleAbort
func (r *defaultRouter) HandleAbort(c peer.NodePeer, msg message.Message) (message.Message, error) {
r.eventChan <- &peer.OnPeerAbortedEvent{c.Node(), peer.PeerStatusAbort}
c.State(peer.PeerStatusAbort)
c.Exit()
return nil, nil
}
示例2: HandleHello
//HandleHello Request
func (r *defaultRouter) HandleHello(c peer.NodePeer, msg message.Message) (message.Message, error) {
c.Identify(msg.(*message.Hello).From)
if r.exists(c) {
return &message.Abort{Id: msg.(*message.Hello).Id, From: r.from}, nil
}
c.State(peer.PeerStatusConnecting)
return &message.Welcome{Id: msg.(*message.Hello).Id, From: r.from}, nil
}
示例3: HandleAck
func (r *defaultRouter) HandleAck(c peer.NodePeer, msg message.Message) (message.Message, error) {
err := r.accept(c)
if err != nil {
log.Println("Unexpected Error accepting Peer on HandleAck ", c.Node(), "msg:", msg)
}
c.State(peer.PeerStatusConnected)
r.eventChan <- &peer.OnPeerConnectedEvent{msg.(*message.Ack).From, peer.PeerStatusConnected, c.Mode()}
go r.watcher.Watch(c)
return nil, nil
}
示例4: HandleWelcome
//HandleWelcome Request
func (r *defaultRouter) HandleWelcome(c peer.NodePeer, msg message.Message) (message.Message, error) {
err := r.accept(c)
if err != nil {
r.eventChan <- &peer.OnPeerErroredEvent{c.Node(), peer.PeerStatusError, err}
return &message.Error{Id: msg.(*message.Welcome).Id, From: r.from}, err
}
c.State(peer.PeerStatusConnected)
r.eventChan <- &peer.OnPeerConnectedEvent{c.Node(), peer.PeerStatusConnected, c.Mode()}
go r.watcher.Watch(c)
return &message.Ack{Id: msg.(*message.Welcome).Id, From: r.from}, nil
}