'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Dim broker As MqttBroker
End Sub
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
'If srvr.CurrentThreadIndex = 0 Then 'main thread
LogError(StackTrace)
Return False
'Else 'handlers threads
' Return True
'End If
End Sub
Sub AppStart (Args() As String)
'record broker PID assigned on server
Dim jo As JavaObject
jo.InitializeStatic("java.lang.management.ManagementFactory")
Dim pid As String = jo.RunMethodJO("getRuntimeMXBean",Null).RunMethod("getName",Null)
File.WriteString(File.DirApp,"brokerpid.txt","EggBroker: "& pid.SubString2(0,pid.IndexOf("@")))
'set and start the broker
broker.Initialize("", 51212) 'first parameter is the event name. It is currently not used.
broker.SetUserAndPassword("tstuser","tstpwd*")
broker.Start
StartMessageLoop 'Non-UI app
End Sub