{
// // Instantiate master thread that manages the request pool
// downloadMaster = new Thread(DownloadThread);
// downloadMaster.Name = "TexturePipeline";
// downloadMaster.IsBackground = true;
downloadMaster = new EventTimer(new TimerTask(){
@Override
public void run() {
if(_Running)
DownloadThread();
}
});
}
_Running = true;
eventObservers.put(PacketType.ImageData, new EventObserver<PacketReceivedEventArgs>()
{
@Override
public void handleEvent(Observable o,PacketReceivedEventArgs arg) {
try{ ImageDataHandler(o, arg);}
catch(Exception e) {JLogger.warn(Utils.getExceptionStackTraceAsString(e));}
}}
);
eventObservers.put(PacketType.ImagePacket, new EventObserver<PacketReceivedEventArgs>()
{
@Override
public void handleEvent(Observable o,PacketReceivedEventArgs arg) {
try{ ImagePacketHandler(o, arg);}
catch(Exception e) {JLogger.warn(Utils.getExceptionStackTraceAsString(e));}
}}
);
eventObservers.put(PacketType.ImageNotInDatabase, new EventObserver<PacketReceivedEventArgs>()
{
@Override
public void handleEvent(Observable o,PacketReceivedEventArgs arg) {
try{ ImageNotInDatabaseHandler(o, arg);}
catch(Exception e) {JLogger.warn(Utils.getExceptionStackTraceAsString(e));}
}}
);
for(Entry<PacketType, EventObserver<PacketReceivedEventArgs>> e : eventObservers.entrySet())
{
_Client.network.RegisterCallback(e.getKey(), e.getValue());
}
// _Client.network.RegisterCallback(PacketType.ImageData, ImageDataHandler);
// _Client.network.RegisterCallback(PacketType.ImagePacket, ImagePacketHandler);
// _Client.network.RegisterCallback(PacketType.ImageNotInDatabase, ImageNotInDatabaseHandler);
downloadMaster.schedule(500, 500);
if (RefreshDownloadsTimer == null)
{
RefreshDownloadsTimer = new EventTimer(new TimerTask(){
@Override
public void run() {
RefreshDownloadsTimer_Elapsed();
}
});