//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 }
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 }