Platforms to show: All Mac Windows Linux Cross-Platform
/MacOSX/Bonjour old/Find computer Old
Required plugins for this example: MBS MacOSX Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacOSX/Bonjour old/Find computer Old
This example is the version from Fri, 13th Oct 2016.
Project "Find computer Old.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
End Control
EventHandler Sub Open()
StartBrowse "_afpovertcp._tcp","Apple File Sharing"
StartBrowse "_nfs._tcp","Network File System"
StartBrowse "_http._tcp","Webserver"
StartBrowse "_printer._tcp","Printer"
StartBrowse "_ichat._tcp","iChat (old)"
StartBrowse "_presence._tcp","iChat"
StartBrowse "_daap._tcp","iTunes"
StartBrowse "_dpap._tcp","iPhoto"
StartBrowse "_ipp._tcp","Intenet Printing Protocol"
StartBrowse "_pdl-datastream._tcp","PDL Data Stream"
StartBrowse "_distcc._tcp","XCode"
StartBrowse "_xserveraid._tcp","XServe RAID"
if TargetWin32 then
MsgBox "The Old DNSServiceDiscovery API does work on Mac OS X 10.2, but not on Windows."
end if
End EventHandler
Sub ClearLookups()
dim l as MyLookup
dim i,c as integer
c=UBound(lookup)
for i=c downto 0
if lookup(i).done then
lookup.Remove i
end if
next
End Sub
Protected Sub StartBrowse(typ as string, reason as string)
dim b as MyBrowser
b=new MyBrowser
if b.Browse(typ,"") then
b.Reason=reason
browser.Append b
else
List.AddRow "Failed to init browser for "+typ
end if
End Sub
Sub StartLookup(name as string, type as string, domain as string, reason as string)
dim b as MyLookup
ClearLookups
b=new MyLookup
if b.Lookup(name,type,domain) then
b.Reason=reason
b.name=name
lookup.Append b
end if
End Sub
Property Protected browser() As MyBrowser
Property Protected lookup() As MyLookup
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Class MyBrowser Inherits DNSServiceDiscoveryBrowseMBS
EventHandler Sub ServiceBrowse(message as integer, name as string, type as string, domain as string, flags as integer)
if message=0 then
// added
Window1.StartLookup name,type,domain,reason
elseif message=1 then
// removed
Window1.List.AddRow name
Window1.List.Cell(Window1.List.LastIndex,1)="gone"
Window1.List.Cell(Window1.List.LastIndex,2)=""
Window1.List.Cell(Window1.List.LastIndex,3)=reason
end if
End EventHandler
Property reason As string
End Class
Class MyLookup Inherits DNSServiceDiscoveryResolveMBS
EventHandler Sub ServiceLookup(ip as string, port as integer, text as string, flags as integer)
dim l as listbox
l=Window1.List
l.addrow name
l.Cell(l.LastIndex,1)=ip+":"+str(port)
l.Cell(l.LastIndex,2)=text
l.Cell(l.LastIndex,3)=reason
End EventHandler
Property done As boolean
Property name As string
Property reason As string
End Class
End Project
See also:
The items on this page are in the following plugins: MBS MacOSX Plugin.