network

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package network says whether the phone is online, and how.

nimbus native plugin add network

s, err := network.Get(ctx)
network.Watch(ctx, func(s network.Status) { setOnline(s.Connected) })

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Watch

func Watch(ctx context.Context, f func(Status)) error

Watch calls f with the connection now and whenever it changes, until ctx ends. It blocks, so run it from a goroutine in an effect.

Types

type Status

type Status struct {
	Connected bool   `json:"connected"` // whether it is online
	Type      string `json:"type"`      // "wifi", "cellular", "wired", "other" or "none"
	Expensive bool   `json:"expensive"` // metered, such as mobile data
	Address   string `json:"address"`   // the phone's IP on this network, not its public one
	Airplane  bool   `json:"airplane"`  // airplane mode; Android only, as iOS doesn't say
}

Status is the phone's connection.

func Get

func Get(ctx context.Context) (Status, error)

Get returns the connection now.

Jump to

Keyboard shortcuts

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