Documentation ¶
Index ¶
- Constants
- func HandleFoundPeer(sRemotePID string) bool
- func HandleLostPeer(sRemotePID string)
- func ProximityTransportConstructor(ctx context.Context, l *zap.Logger) func(h host.Host, u *tptu.Upgrader) (*ProximityTransport, error)
- func ReceiveFromPeer(remotePID string, payload []byte)
- type Addr
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) LocalMultiaddr() ma.Multiaddr
- func (c *Conn) Read(payload []byte) (n int, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) RemoteMultiaddr() ma.Multiaddr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(payload []byte) (n int, err error)
- type Listener
- type ProximityTransport
- func (t *ProximityTransport) CanDial(remoteMa ma.Multiaddr) bool
- func (t *ProximityTransport) Dial(ctx context.Context, remoteMa ma.Multiaddr, remotePID peer.ID) (tpt.CapableConn, error)
- func (t *ProximityTransport) Listen(localMa ma.Multiaddr) (tpt.Listener, error)
- func (t *ProximityTransport) Protocols() []int
- func (t *ProximityTransport) Proxy() bool
- func (t *ProximityTransport) String() string
Constants ¶
const DefaultBind = "/mc/Qmeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
Variables ¶
This section is empty.
Functions ¶
func HandleFoundPeer ¶
HandleFoundPeer is called by the native driver when a new peer is found. Adds the peer in the PeerStore and initiates a connection with it
func HandleLostPeer ¶ added in v2.187.1
func HandleLostPeer(sRemotePID string)
HandleLostPeer is called by the native driver when the connection with the peer is lost. Closes connections with the peer.
func ProximityTransportConstructor ¶ added in v2.187.1
func ReceiveFromPeer ¶
ReceiveFromPeer is called by native driver when peer's device sent data.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is the equivalent of a net.Conn object. It is the result of calling the Dial or Listen functions in this package, with associated local and remote Multiaddrs.
func (*Conn) Close ¶
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*Conn) LocalMultiaddr ¶
LocalMultiaddr returns the local Multiaddr associated with this connection.
func (*Conn) RemoteAddr ¶
LocalAddr returns the remote network address.
func (*Conn) RemoteMultiaddr ¶
RemoteMultiaddr returns the remote Multiaddr associated with this connection.
func (*Conn) SetDeadline ¶
Noop deadline methods, handled by the native driver.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener is an interface closely resembling the net.Listener interface. The only real difference is that Accept() returns Conn's of the type in this package, and also exposes a Multiaddr method as opposed to a regular Addr method.
func (*Listener) Accept ¶
func (l *Listener) Accept() (tpt.CapableConn, error)
Accept waits for and returns the next connection to the listener. Returns a Multiaddr friendly Conn.
type ProximityTransport ¶ added in v2.187.1
type ProximityTransport struct {
// contains filtered or unexported fields
}
ProximityTransport represents any device by which you can connect to and accept connections from other peers.
func (*ProximityTransport) CanDial ¶ added in v2.187.1
func (t *ProximityTransport) CanDial(remoteMa ma.Multiaddr) bool
CanDial returns true if this transport believes it can dial the given multiaddr.
func (*ProximityTransport) Dial ¶ added in v2.187.1
func (t *ProximityTransport) Dial(ctx context.Context, remoteMa ma.Multiaddr, remotePID peer.ID) (tpt.CapableConn, error)
Dial dials the peer at the remote address. With proximity connections (e.g. MC, BLE, Nearby) you can only dial a device that is already connected with the native driver.
func (*ProximityTransport) Listen ¶ added in v2.187.1
Listen listens on the given multiaddr. Proximity connections can't listen on more than one listener.
func (*ProximityTransport) Protocols ¶ added in v2.187.1
func (t *ProximityTransport) Protocols() []int
Protocols returns the set of protocols handled by this transport.
func (*ProximityTransport) Proxy ¶ added in v2.187.1
func (t *ProximityTransport) Proxy() bool
Proxy returns true if this transport proxies.
func (*ProximityTransport) String ¶ added in v2.187.1
func (t *ProximityTransport) String() string