Platforms to show: All Mac Windows Linux Cross-Platform

/MacOSX/Bonjour old/Bonjour 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/Bonjour Old

This example is the version from Fri, 13th Oct 2016.

Project "Bonjour Old.xojo_binary_project"
Class Window1 Inherits Window
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control TabPanel1 Inherits TabPanel
ControlInstance TabPanel1 Inherits TabPanel
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control StaticText6 Inherits Label
ControlInstance StaticText6 Inherits Label
End Control
Control Rservicename Inherits TextField
ControlInstance Rservicename Inherits TextField
End Control
Control Rservicetype Inherits TextField
ControlInstance Rservicetype Inherits TextField
End Control
Control Rdomain Inherits TextField
ControlInstance Rdomain Inherits TextField
End Control
Control Rport Inherits TextField
ControlInstance Rport Inherits TextField
End Control
Control Rtext Inherits TextField
ControlInstance Rtext Inherits TextField
End Control
Control TypelistButton Inherits PushButton
ControlInstance TypelistButton Inherits PushButton
EventHandler Sub Action() // URL from Apple's docs showurl "http://www.iana.org/assignments/port-numbers" End EventHandler
End Control
Control RegisterButton Inherits PushButton
ControlInstance RegisterButton Inherits PushButton
EventHandler Sub Action() if r.Register(Rservicename.text,Rservicetype.text, Rdomain.text, val(Rport.text),Rtext.text) then MsgBox "Registering started successfull." else MsgBox "Registering failed." end if End EventHandler
End Control
Control StaticText7 Inherits Label
ControlInstance StaticText7 Inherits Label
End Control
Control StaticText8 Inherits Label
ControlInstance StaticText8 Inherits Label
End Control
Control StaticText9 Inherits Label
ControlInstance StaticText9 Inherits Label
End Control
Control lServicename Inherits TextField
ControlInstance lServicename Inherits TextField
End Control
Control lservicetype Inherits TextField
ControlInstance lservicetype Inherits TextField
End Control
Control ldomain Inherits TextField
ControlInstance ldomain Inherits TextField
End Control
Control LookupButton Inherits PushButton
ControlInstance LookupButton Inherits PushButton
EventHandler Sub Action() if l.Lookup(lServicename.text,lservicetype.text, ldomain.text) then MsgBox "Lookup started successfull." else MsgBox "Lookup failed." end if End EventHandler
End Control
Control StaticText10 Inherits Label
ControlInstance StaticText10 Inherits Label
End Control
Control StaticText11 Inherits Label
ControlInstance StaticText11 Inherits Label
End Control
Control bServicename Inherits TextField
ControlInstance bServicename Inherits TextField
End Control
Control bdomain Inherits TextField
ControlInstance bdomain Inherits TextField
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() if b.Browse(bServicename.text,bdomain.text) then MsgBox "Browse started successfull." else MsgBox "Browse failed." end if End EventHandler
End Control
Control RadioEnumerate Inherits RadioButton
ControlInstance RadioEnumerate(0) Inherits RadioButton
ControlInstance RadioEnumerate(1) Inherits RadioButton
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() dim n as integer if RadioEnumerate(0).Value then n=1 // recommended registration domains else n=0 // recommended browsing domains end if if e.EnumerateDomains(n) then MsgBox "Enumerating started successfull." else MsgBox "Enumerating failed." end if End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() r.Close End EventHandler
End Control
Control PushButton4 Inherits PushButton
ControlInstance PushButton4 Inherits PushButton
EventHandler Sub Action() dim s as string // a TXT Record is built of Pascal Strings // one byte for len + content // you can attach severals, but it should be only 100 bytes or so // see http://www.zeroconf.org/Bonjour/txtrecords.html s=Rtext.text s=chr(len(s))+s title=str(r.UpdateText(s,200000)) End EventHandler
End Control
EventHandler Sub Close() b.close e.close r.close l.Close End EventHandler
EventHandler Sub Open() b=new MyBonjourBrowseMBS r=new MyBonjourRegisterMBS e=new MyBonjourDomainEnumerationMBS l=new MyBonjourLookupMBS if b.Available then write "Rendevouz is available." else msgBox "No Rendevouz found!" quit end if 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 write(s as string) listBox1.addrow s listBox1.scrollPosition=listBox1.listcount End Sub
Property b As myBonjourbrowseMBS
Property e As myBonjourdomainEnumerationMBS
Property l As myBonjourlookupMBS
Property r As myBonjourregisterMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class MyBonjourBrowseMBS Inherits DNSServiceDiscoveryBrowseMBS
EventHandler Sub ServiceBrowse(message as integer, name as string, type as string, domain as string, flags as integer) window1.write "ServiceBrowse event." Window1.write " Name: "+name Window1.write " Type: "+type Window1.write " Domain: "+domain Window1.write " Flags: "+str(flags) Window1.write " Message: "+str(message) End EventHandler
End Class
Class MyBonjourDomainEnumerationMBS Inherits DNSServiceDiscoveryDomainEnumerationMBS
EventHandler Sub ServiceDomainEnumeration(message as integer, domain as string, flags as integer) Window1.write "ServiceDomainEnumeration event." Window1.write " Domain: "+domain Window1.write " Flags: "+str(flags) Window1.write " Message: "+str(message) End EventHandler
End Class
Class MyBonjourLookupMBS Inherits DNSServiceDiscoveryResolveMBS
EventHandler Sub ServiceLookup(ip as string, port as integer, text as string, flags as integer) window1.write "ServiceLookup event." window1.write " IP: "+ip window1.write " Port: "+str(port) window1.write " Text: "+text End EventHandler
End Class
Class MyBonjourRegisterMBS Inherits DNSServiceDiscoveryRegisterMBS
EventHandler Sub ServiceRegistration(errorcode as integer) window1.write "ServiceRegistration event." window1.write " Errorcode: "+str(errorcode) End EventHandler
End Class
Class App Inherits Application
End Class
End Project

See also:

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


The biggest plugin in space...