This commit is contained in:
sirjonasxx 2020-05-11 14:51:17 +02:00
parent 215616043d
commit 764d0fbcbc
4 changed files with 25 additions and 23 deletions

View File

@ -0,0 +1,7 @@
package gearth.protocol.packethandler;
public interface OnDatastreamConfirmedListener {
void confirm(String hotelVersion);
}

View File

@ -1,5 +1,6 @@
package gearth.protocol.packethandler; package gearth.protocol.packethandler;
import gearth.misc.listenerpattern.Observable;
import gearth.protocol.HMessage; import gearth.protocol.HMessage;
import gearth.protocol.HPacket; import gearth.protocol.HPacket;
@ -7,6 +8,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Consumer;
public class OutgoingPacketHandler extends PacketHandler { public class OutgoingPacketHandler extends PacketHandler {
@ -14,12 +16,11 @@ public class OutgoingPacketHandler extends PacketHandler {
super(outputStream, trafficObservables); super(outputStream, trafficObservables);
} }
private List<OnDatastreamConfirmedListener> onDatastreamConfirmedListeners = new ArrayList<>();
private Observable<OnDatastreamConfirmedListener> datastreamConfirmedObservable = new Observable<>();
public void addOnDatastreamConfirmedListener(OnDatastreamConfirmedListener listener) { public void addOnDatastreamConfirmedListener(OnDatastreamConfirmedListener listener) {
onDatastreamConfirmedListeners.add(listener); datastreamConfirmedObservable.addListener(listener);
}
public interface OnDatastreamConfirmedListener {
void confirm(String hotelVersion);
} }
private void dataStreamCheck(byte[] buffer) { private void dataStreamCheck(byte[] buffer) {
@ -28,9 +29,7 @@ public class OutgoingPacketHandler extends PacketHandler {
isDataStream = (hpacket.getBytesLength() > 6 && hpacket.length() < 100); isDataStream = (hpacket.getBytesLength() > 6 && hpacket.length() < 100);
if (isDataStream) { if (isDataStream) {
String version = hpacket.readString(); String version = hpacket.readString();
for (OnDatastreamConfirmedListener listener : onDatastreamConfirmedListeners) { datastreamConfirmedObservable.fireEvent(l -> l.confirm(version));
listener.confirm(version);
}
} }
} }
} }

View File

@ -81,20 +81,20 @@ public class NetworkExtensionInfo {
public static class OUTGOING_MESSAGES_IDS { public static class OUTGOING_MESSAGES_IDS {
public static final int ONDOUBLECLICK = 1; public static final int ONDOUBLECLICK = 1;
public static final int INFOREQUEST = 2; // backend: implemented public static final int INFOREQUEST = 2;
public static final int PACKETINTERCEPT = 3; // backend: implemented public static final int PACKETINTERCEPT = 3;
public static final int FLAGSCHECK = 4; // backend: implemented public static final int FLAGSCHECK = 4;
public static final int CONNECTIONSTART = 5; // backend: implemented public static final int CONNECTIONSTART = 5;
public static final int CONNECTIONEND = 6; // backend: implemented public static final int CONNECTIONEND = 6;
public static final int INIT = 7; // backend: implemented public static final int INIT = 7;
} }
public static class INCOMING_MESSAGES_IDS { public static class INCOMING_MESSAGES_IDS {
public static final int EXTENSIONINFO = 1; // backend: implemented public static final int EXTENSIONINFO = 1;
public static final int MANIPULATEDPACKET = 2; // backend: implemented public static final int MANIPULATEDPACKET = 2;
public static final int REQUESTFLAGS = 3; // backend: implemented public static final int REQUESTFLAGS = 3;
public static final int SENDMESSAGE = 4; // backend: implemented public static final int SENDMESSAGE = 4;
public static final int EXTENSIONCONSOLELOG = 98; public static final int EXTENSIONCONSOLELOG = 98;
} }

View File

@ -5,13 +5,9 @@ package gearth.services.extensionhandler.extensions.implementations.network.exec
*/ */
public class ExtensionRunnerFactory { public class ExtensionRunnerFactory {
private static ExtensionRunner runner = obtain(); private static ExtensionRunner runner = new NormalExtensionRunner();
public static ExtensionRunner get() { public static ExtensionRunner get() {
return runner; return runner;
} }
private static ExtensionRunner obtain() {
return new NormalExtensionRunner();
}
} }