mirror of
https://bitbucket.org/projectswg/lightspeed.git
synced 2026-10-01 17:12:55 -04:00
Massive refactoring and fixed the client
This commit is contained in:
@@ -28,22 +28,29 @@
|
||||
package com.projectswg.lightspeed_frontend.communication;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.projectswg.common.control.Assert;
|
||||
import com.projectswg.common.debug.Assert;
|
||||
import com.projectswg.common.network.packets.Packet;
|
||||
import com.projectswg.common.utilities.ThreadUtilities;
|
||||
|
||||
public class FrontendCommunication {
|
||||
|
||||
private final AtomicBoolean running;
|
||||
|
||||
private ExecutorService executor;
|
||||
private ResponseCallback callback;
|
||||
private InetSocketAddress address;
|
||||
|
||||
public FrontendCommunication() {
|
||||
running = new AtomicBoolean(false);
|
||||
callback = null;
|
||||
address = null;
|
||||
}
|
||||
|
||||
public void setCallback(ResponseCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public void setAddress(InetSocketAddress address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
@@ -51,7 +58,6 @@ public class FrontendCommunication {
|
||||
Assert.fail();
|
||||
return false;
|
||||
}
|
||||
executor = Executors.newSingleThreadExecutor(ThreadUtilities.newThreadFactory("frontend-communication"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -60,25 +66,18 @@ public class FrontendCommunication {
|
||||
Assert.fail();
|
||||
return false;
|
||||
}
|
||||
executor.shutdownNow();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return false;
|
||||
public Packet send(Packet packet) {
|
||||
Packet response = HttpClient.requestPacket(address, packet);
|
||||
if (response != null && callback != null)
|
||||
callback.onPacket(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
public void connect(InetSocketAddress addr) {
|
||||
if (addr == null)
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
|
||||
}
|
||||
|
||||
public void send(Packet p) {
|
||||
|
||||
public interface ResponseCallback {
|
||||
void onPacket(Packet packet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user