I’m trying to add a handler to the Monkeybread DNSServiceBrowseMBS.ServiceBrowse event but getting a syntax error. The event definition is here.
sub ServiceBrowse(Flags as Integer, InterfaceIndex as Integer, ErrorCode as Integer, ServiceName as string, RegType as string, Domain as string)
My handler is
Sub dnsS_ServiceBrowse(dnsB as DNSServiceBrowseMBS, Flags as Integer, InterfaceIndex as Integer, ErrorCode as Integer, ServiceName as string, RegType as string, Domain as string)
End Sub
I create the object and try to add a handler with this code in a constructor
Var dnsS_browser As DNSServiceBrowseMBS ’ In fact this is a global in the class but I’m showing the definition here
dnsS_browser = New DNSServiceBrowseMBS
AddHandler dnsS_browser.ServiceBrowse, AddressOf dnsS_ServiceBrowse, Flags, InterfaceIndex, ErrorCode, ServiceName, RegType, Domain
And I get a SyntaxError at the AddHandler with no other information. Interestingly if I create a mismatch in the types Xojo will complete about not matching the expected Delegate and display the types in both the expected and my erroneous definition correctly.
I asked Christian and he said that the AddHandler should work with DNSServiceBrowseMBS so I assume I’m simply doing something wrong. Maybe another set of eyes can tell me what.
Xojo Version 2021 Release 3.1 (yeah, I know I should probably udpate)