Example: /MacOSX/NWPathMonitor Test

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/MacOSX/NWPathMonitor Test


You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacOSX/NWPathMonitor Test

This example is the version from Tue, 29th Jan 2024.

Project "NWPathMonitor Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub ExpandRow(row As Integer) Dim value As Variant = Me.RowTag(row) AddValue value End EventHandler
End Control
EventHandler Sub Close() Monitor.Cancel End EventHandler
EventHandler Sub Open() Monitor = New NWPathMonitor monitor.List = List monitor.Start End EventHandler
Sub AddValue(value as Variant) If value IsA NWPathMBS Then Dim path As NWPathMBS = value List.AddRow "HasDNS", path.HasDNS.YesNo List.AddRow "HasIPv4", path.HasIPv4.YesNo List.AddRow "HasIPv6", path.HasIPv6.YesNo List.AddRow "IsConstrained", path.IsConstrained.YesNo List.AddRow "IsExpensive", path.IsExpensive.YesNo List.AddRow "Uses Cellular", path.UsesInterfaceType(NWInterfaceMBS.kInterfaceTypeCellular).YesNo List.AddRow "Uses Wifi", path.UsesInterfaceType(NWInterfaceMBS.kInterfaceTypeWifi).YesNo List.AddRow "Uses Wired", path.UsesInterfaceType(NWInterfaceMBS.kInterfaceTypeWired).YesNo List.AddFolder "Interfaces", path.Interfaces List.AddFolder "EffectiveLocalEndPoint", path.EffectiveLocalEndPoint List.AddFolder "EffectiveRemoteEndPoint", path.EffectiveRemoteEndPoint List.AddFolder "Gateways", path.Gateways Dim StatusText As String Select Case path.Status Case path.kStatusSatisfiable StatusText = "Satisfiable" Case path.kStatusUnsatisfied StatusText = "Unsatisfied" Case path.kStatusSatisfied StatusText = "Satisfied" Case path.kStatusInvalid StatusText = "Invalid" End Select List.AddRow "Status", path.Status.ToString+" "+StatusText ElseIf value IsA NWInterfaceMBS Then Dim inter As NWInterfaceMBS = value List.AddRow "Index", inter.Index.ToString List.AddRow "Name", inter.Name Dim TypeText As String Select Case inter.Type Case inter.kInterfaceTypeCellular TypeText = "Cellular" Case inter.kInterfaceTypeLoopback TypeText = "Lookback" Case inter.kInterfaceTypeOther TypeText = "Other" Case inter.kInterfaceTypeWifi TypeText = "Wifi" Case inter.kInterfaceTypeWired TypeText = "Wired" End Select List.AddRow "Type", inter.Type.ToString+" "+TypeText ElseIf value IsA NWEndPointMBS Then Dim endpoint As NWEndPointMBS = value List.AddRow "AddressString", endpoint.AddressString List.AddRow "HostName", endpoint.HostName List.AddRow "PortString", endpoint.PortString List.AddRow "URL", endpoint.URL ElseIf value.IsArray Then #Pragma BreakOnExceptions False Try Dim values() As NWInterfaceMBS = value For Each o As NWInterfaceMBS In values AddValue o Next Return Catch t As TypeMismatchException // ignore End Try Try Dim values() As NWEndPointMBS = value For Each o As NWEndPointMBS In values AddValue o Next Return Catch t As TypeMismatchException // ignore End Try End If End Sub
Property Monitor As NWPathMonitor
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
MenuItem HelpMenu = "&Help"
End MenuBar
Sign
End Sign
Class NWPathMonitor Inherits NWPathMonitorMBS
EventHandler Sub Cancel() List.AddRow "Cancel" End EventHandler
EventHandler Sub Update(path as NWPathMBS) List.AddFolder "Update", path list.Expanded(List.LastIndex) = True End EventHandler
Property List As listbox
End Class
Module UtilModule
Sub AddFolder(extends list as listbox, name as string, RowTag as Variant) list.AddFolder name list.RowTag(list.LastIndex) = RowTag End Sub
Function YesNo(Extends b as Boolean) As string If b Then Return "Yes" Else Return "No" End If End Function
End Module
End Project

The items on this page are in the following plugins: MBS MacOSX Plugin.


💬 Ask a question or report a problem