package Multicast;
import Common.JsonObject;
import java.net.DatagramPacket;
public class MulticastJsonReceivingThread extends MulticastReceiveSingleObject
{
public MulticastJsonReceivingThread(int port, String ip_group, T value)
{
super(port, ip_group, value);
}
@Override
public int getDataMaxSize()
{
try
{
return this.getValue().maxPacketSize();
}
catch (Exception e)
{
e.printStackTrace();
}
return -1;
}
public T getJsonObject() throws InterruptedException
{
T jsonObject;
synchronized (this.dataMutex)
{
jsonObject = this.getValue();
}
return jsonObject;
}
@Override
public void handleDatagram(DatagramPacket packet)
{
synchronized (this.dataMutex)
{
try
{
this.getValue().loadValue(packet);
this.valueChanged();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}