package network

import (
	ma 
)

// Notifiee is an interface for an object wishing to receive
// notifications from a Network.
type Notifiee interface {
	Listen(Network, ma.Multiaddr)      // called when network starts listening on an addr
	ListenClose(Network, ma.Multiaddr) // called when network stops listening on an addr
	Connected(Network, Conn)           // called when a connection opened
	Disconnected(Network, Conn)        // called when a connection closed
}

// NotifyBundle implements Notifiee by calling any of the functions set on it,
// and nop'ing if they are unset. This is the easy way to register for
// notifications.
type NotifyBundle struct {
	ListenF      func(Network, ma.Multiaddr)
	ListenCloseF func(Network, ma.Multiaddr)

	ConnectedF    func(Network, Conn)
	DisconnectedF func(Network, Conn)
}

var _ Notifiee = (*NotifyBundle)(nil)

// Listen calls ListenF if it is not null.
func ( *NotifyBundle) ( Network,  ma.Multiaddr) {
	if .ListenF != nil {
		.ListenF(, )
	}
}

// ListenClose calls ListenCloseF if it is not null.
func ( *NotifyBundle) ( Network,  ma.Multiaddr) {
	if .ListenCloseF != nil {
		.ListenCloseF(, )
	}
}

// Connected calls ConnectedF if it is not null.
func ( *NotifyBundle) ( Network,  Conn) {
	if .ConnectedF != nil {
		.ConnectedF(, )
	}
}

// Disconnected calls DisconnectedF if it is not null.
func ( *NotifyBundle) ( Network,  Conn) {
	if .DisconnectedF != nil {
		.DisconnectedF(, )
	}
}

// Global noop notifiee. Do not change.
var GlobalNoopNotifiee = &NoopNotifiee{}

type NoopNotifiee struct{}

var _ Notifiee = (*NoopNotifiee)(nil)

func ( *NoopNotifiee) ( Network,  Conn)           {}
func ( *NoopNotifiee) ( Network,  Conn)        {}
func ( *NoopNotifiee) ( Network,  ma.Multiaddr)      {}
func ( *NoopNotifiee) ( Network,  ma.Multiaddr) {}