Example #1
0
// NewStream returns a new stream to given peer p.
// If there is no connection to p, attempts to create one.
func (n *Network) NewStream(p peer.ID) (inet.Stream, error) {
	log.Debugf("[%s] network opening stream to peer [%s]", n.local, p)
	s, err := n.Swarm().NewStreamWithPeer(p)
	if err != nil {
		return nil, err
	}

	return inet.Stream(s), nil
}
Example #2
0
func (n *ps2netNotifee) ClosedStream(s *ps.Stream) {
	n.not.ClosedStream(n.net, inet.Stream((*Stream)(s)))
}
Example #3
0
func (n *ps2netNotifee) OpenedStream(s *ps.Stream) {
	n.not.OpenedStream(n.net, inet.Stream((*Stream)(s)))
}
Example #4
0
// NewStream returns a new Stream from this connection
func (c *Conn) NewStream() (inet.Stream, error) {
	s, err := c.NewSwarmStream()
	return inet.Stream(s), err
}