Sub Process_Globals
Private udp As UDPSocket
End Sub
Sub AppStart (Args() As String)
CreateMulticastSocket("udp", 1900, "239.255.255.250")
StartMessageLoop
End Sub
Sub CreateMulticastSocket (EventName As String, Port As Int, Group As String)
Dim multi As JavaObject
multi.InitializeNewInstance("java.net.MulticastSocket", Array(Port))
Dim inet As JavaObject
multi.RunMethod("joinGroup", Array(inet.InitializeStatic("java.net.InetAddress").RunMethod("getByName", Array(Group))))
Dim jo As JavaObject = Me
jo.RunMethod("SetMulticastSocket", Array(EventName, multi, udp))
End Sub
#if java
import java.net.*;
public static void SetMulticastSocket (String EventName, MulticastSocket socket, anywheresoftware.b4a.objects.SocketWrapper.UDPSocket udp) {
udp.init(ba, EventName, 8192, socket);
}
#end if