Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/NSNetService/Bonjour Browser Console


Required plugins for this example: MBS MacFrameworks Plugin, MBS MacCocoa Plugin, MBS MacBase Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacFrameworks/NSNetService/Bonjour Browser Console

This example is the version from Sat, 19th Feb 2021.

Project "Bonjour Browser Console.xojo_binary_project"
Class App Inherits ConsoleApplication
EventHandler Function Run(args() as String) As Integer Const domain = "local." // default const type = "_test._tcp." const name = "My Test Service" const port = 12345 testService = new NetworkService(domain, type, name, port) testService.publish do // run event loop once NSRunLoopMBS.currentRunLoop.runOnce DoEvents loop End EventHandler
EventHandler Function UnhandledException(error As RuntimeException) As Boolean End EventHandler
Property testService As Networkservice
End Class
Class NetworkService Inherits NSNetServiceMBS
EventHandler Sub DidNotPublish(Error as Dictionary) Print CurrentMethodName Dim ErrorCode As Integer = error.Lookup(NSNetServicesErrorCode, "") Dim errorDomain As String = error.Lookup(NSNetServicesErrorDomain, "") Print "Did not publish with errorcode: "+Str(ErrorCode) End EventHandler
EventHandler Sub DidNotResolve(Error as Dictionary) print CurrentMethodName Dim ErrorCode As Integer = error.Lookup(NSNetServicesErrorCode, "") Dim errorDomain As String = error.Lookup(NSNetServicesErrorDomain, "") Print "Did not resolve with errorcode: "+Str(ErrorCode) End EventHandler
EventHandler Sub DidPublish() print CurrentMethodName print "Did publish" End EventHandler
EventHandler Sub DidResolveAddress() print CurrentMethodName print "Did resolve address for "+me.name+" with type "+me.type+": "+me.addressIPv4+":"+str(me.port) '+Join(me.addresses, ", ") End EventHandler
EventHandler Sub DidStop() print CurrentMethodName print "Did stop" End EventHandler
EventHandler Sub DidUpdateTXTRecordData(data as MemoryBlock) print CurrentMethodName dim s as string = data if encodings.UTF8.IsValidData(s) then s = DefineEncoding(S, encodings.UTF8) else s = DefineEncoding(s, encodings.ISOLatin1) end if print "Did update text record: "+s End EventHandler
EventHandler Sub WillPublish() print CurrentMethodName print "Will publish" End EventHandler
EventHandler Sub WillResolve() print CurrentMethodName print "Will resolve "+me.name+" of type "+me.type End EventHandler
End Class
End Project

See also:

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


The biggest plugin in space...