netmanager

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2023 License: Apache-2.0, MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectivityCellularType

type ConnectivityCellularType int
const (
	ConnectivityCellularUnknown ConnectivityCellularType = iota
	ConnectivityCellularNone
	ConnectivityCellular2G
	ConnectivityCellular3G
	ConnectivityCellular4G
	ConnectivityCellular5G
)

func ParseConnectivityCellularType added in v1.4.0

func ParseConnectivityCellularType(s string) (ConnectivityCellularType, error)

func (ConnectivityCellularType) String

func (cct ConnectivityCellularType) String() string

type ConnectivityInfo

type ConnectivityInfo struct {
	// False when the device is not connected to a network.
	State ConnectivityState

	// True when the device is connected to a metered network.
	Metering ConnectivityState

	// True when the device is connected to a bluetooth network.
	Bluetooth ConnectivityState

	// The type of the network the device is connected to: wifi/ethernet/cellular.
	NetType ConnectivityNetType

	// If the device is connected to a cellular network:
	// The type of the cellular network the device is connected to: 2G/3G/4G/5G.
	CellularType ConnectivityCellularType
}

func (ConnectivityInfo) String

func (ci ConnectivityInfo) String() string

type ConnectivityNetType

type ConnectivityNetType int
const (
	ConnectivityNetUnknown ConnectivityNetType = iota
	ConnectivityNetNone
	ConnectivityNetWifi
	ConnectivityNetEthernet
	ConnectivityNetCellular
)

func ParseConnectivityNetType added in v1.4.0

func ParseConnectivityNetType(s string) (ConnectivityNetType, error)

func (ConnectivityNetType) String

func (cnt ConnectivityNetType) String() string

type ConnectivityState

type ConnectivityState int
const (
	ConnectivityStateUnknown ConnectivityState = iota
	ConnectivityStateOff
	ConnectivityStateOn
)

func ParseConnectivityState added in v1.4.0

func ParseConnectivityState(s string) (ConnectivityState, error)

func (ConnectivityState) String

func (cs ConnectivityState) String() string

type EventType

type EventType uint
const (
	ConnectivityStateChanged EventType = 1 << iota
	ConnectivityMeteringChanged
	ConnectivityBluetoothChanged
	ConnectivityNetTypeChanged
	ConnectivityCellularTypeChanged

	ConnectivityChanged = 0 |
		ConnectivityStateChanged |
		ConnectivityMeteringChanged |
		ConnectivityBluetoothChanged |
		ConnectivityNetTypeChanged |
		ConnectivityCellularTypeChanged
)

func (EventType) Has

func (t EventType) Has(other EventType) bool

type NetManager

type NetManager struct {
	// contains filtered or unexported fields
}

func NewNetManager

func NewNetManager(initialState ConnectivityInfo) *NetManager

func NewNoopNetManager added in v1.5.0

func NewNoopNetManager() *NetManager

func (*NetManager) GetCurrentState

func (m *NetManager) GetCurrentState() (state ConnectivityInfo)

GetCurrentState return the current state of the Manager

func (*NetManager) UpdateState

func (m *NetManager) UpdateState(state ConnectivityInfo)

UpdateState update the current state of the Manager

func (*NetManager) WaitForStateChange

func (m *NetManager) WaitForStateChange(ctx context.Context, sourceState *ConnectivityInfo, eventType EventType) (bool, EventType)

WaitForStateChange waits until the currentState changes from sourceState or ctx expires. The eventType argument allow you to filter out the event you want to wait for. A true value is returned in former case and false in latter. The EventType is also returned to know which events has been triggered.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL