summaryrefslogtreecommitdiff
path: root/src/tesseract/objects
diff options
context:
space:
mode:
Diffstat (limited to 'src/tesseract/objects')
-rw-r--r--src/tesseract/objects/remote/RemoteObjectCommunicator.java36
-rw-r--r--src/tesseract/objects/remote/RemoteObjectMenu.java1
-rw-r--r--src/tesseract/objects/tank/Tank.java4
3 files changed, 12 insertions, 29 deletions
diff --git a/src/tesseract/objects/remote/RemoteObjectCommunicator.java b/src/tesseract/objects/remote/RemoteObjectCommunicator.java
index 8c8dc11..86b75cc 100644
--- a/src/tesseract/objects/remote/RemoteObjectCommunicator.java
+++ b/src/tesseract/objects/remote/RemoteObjectCommunicator.java
@@ -22,10 +22,7 @@ public class RemoteObjectCommunicator implements Runnable {
public RemoteObjectCommunicator() {
mySockets = new HashMap<UUID, Socket>();
myRunning = false;
- }
-
-
- public void run() {
+
int port = BASE_PORT;
// Find an open port.
@@ -43,7 +40,10 @@ public class RemoteObjectCommunicator implements Runnable {
return;
}
}
-
+ }
+
+
+ public void run() {
// Listen for connections
while (myRunning) {
try {
@@ -70,31 +70,22 @@ public class RemoteObjectCommunicator implements Runnable {
} catch (IOException e) {
mySockets.remove(id);
- // TODO: REMOVE
- System.out.println(id + " Exception. " + e);
return false;
}
} else {
- // TODO: REMOVE
- System.out.println(id + " has not called home.");
return false;
}
}
private void handleNewSocket(final Socket socket) {
try {
- // TODO: Remove
- System.out.println("New Socket");
DataInputStream in = new DataInputStream(socket.getInputStream());
long msb = in.readLong();
long lsb = in.readLong();
-
- UUID id = new UUID(msb, lsb);
-
- System.out.println("Id is " + id);
-
+ UUID id = new UUID(msb, lsb);
+
mySockets.put(id, socket);
} catch (Exception e) {
@@ -104,15 +95,12 @@ public class RemoteObjectCommunicator implements Runnable {
public int getPort() {
- System.out.print("Blocking for address.");
- while (mySocket == null) {
- // Block until we get a socket.
- System.out.print(".");
+ if (mySocket != null) {
+ return mySocket.getLocalPort();
+
+ } else {
+ return 0;
}
-
- System.out.println();
-
- return mySocket.getLocalPort();
}
}
diff --git a/src/tesseract/objects/remote/RemoteObjectMenu.java b/src/tesseract/objects/remote/RemoteObjectMenu.java
index 610c433..3e3fd46 100644
--- a/src/tesseract/objects/remote/RemoteObjectMenu.java
+++ b/src/tesseract/objects/remote/RemoteObjectMenu.java
@@ -81,7 +81,6 @@ public class RemoteObjectMenu extends JMenu {
public void sendKeyToObjects(final KeyEvent e) {
for (RemoteObject o : myControlledObjects) {
if (!myCommunicator.sendKeyToObject(o.getId(), e)) {
- System.out.println("Send failed to " + o.getId());
//myControlledObjects.remove(o);
// TODO : Remove from menu.
}
diff --git a/src/tesseract/objects/tank/Tank.java b/src/tesseract/objects/tank/Tank.java
index 3e5fbdd..4edcb82 100644
--- a/src/tesseract/objects/tank/Tank.java
+++ b/src/tesseract/objects/tank/Tank.java
@@ -333,10 +333,6 @@ public class Tank extends RemoteObject {
private void writeObject(ObjectOutputStream out)
throws IOException {
out.defaultWriteObject();
-
- System.out.println(whole);
- System.out.println(turret);
- System.out.println(barrel);
}
private void readObject(ObjectInputStream in)