Improves the debugging messages some.
There is something up with the browser interface, and these can help me troubleshoot.
This commit is contained in:
@@ -76,6 +76,15 @@ public class CommandConfirmation implements Serializable
|
|||||||
*/
|
*/
|
||||||
public String getMessage()
|
public String getMessage()
|
||||||
{
|
{
|
||||||
return this.errorCode != null ? this.errorCode.getMessage() : this.message;
|
return this.errorCode != null ? this.errorCode
|
||||||
|
.getMessage() : this.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "CommandConfirmation{" +
|
||||||
|
"message='" + this.getMessage() + '\'' +
|
||||||
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,4 +58,13 @@ public class CommandReturn<T> implements Serializable
|
|||||||
{
|
{
|
||||||
return this.confirmation;
|
return this.confirmation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "CommandReturn{" +
|
||||||
|
"returnValue=" + returnValue +
|
||||||
|
", confirmation=" + confirmation +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,8 @@ public class MessageHandler implements Runnable, MessageSerializer
|
|||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
logger.error("Could not send response message for" + update, e);
|
logger.error("Could not send response message" +
|
||||||
|
" for " + update, e);
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
@@ -145,7 +146,16 @@ public abstract class MessageRunner implements Runnable, MessageSerializer
|
|||||||
/*
|
/*
|
||||||
* Not a response, just a generic update.
|
* Not a response, just a generic update.
|
||||||
*/
|
*/
|
||||||
Object ob = deserializeObject(returnMessage[1]);
|
Object ob;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ob = deserializeObject(returnMessage[1]);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
throw new IOException("Could not " +
|
||||||
|
"deserialize " + Arrays.toString(returnMessage[1]), e);
|
||||||
|
}
|
||||||
this.triggerUpdateListeners(ob);
|
this.triggerUpdateListeners(ob);
|
||||||
logger.debug("Received update {}", ob);
|
logger.debug("Received update {}", ob);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,11 @@
|
|||||||
package edu.regis.universeplayer.browserCommands;
|
package edu.regis.universeplayer.browserCommands;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public interface MessageSerializer
|
public interface MessageSerializer
|
||||||
{
|
{
|
||||||
@@ -43,6 +45,10 @@ public interface MessageSerializer
|
|||||||
*/
|
*/
|
||||||
default Object deserializeObject(byte[] message) throws IOException, ClassNotFoundException
|
default Object deserializeObject(byte[] message) throws IOException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
|
if (message == null || message.length == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try (ByteArrayInputStream byteStream = new ByteArrayInputStream(message))
|
try (ByteArrayInputStream byteStream = new ByteArrayInputStream(message))
|
||||||
{
|
{
|
||||||
try (ObjectInputStream stream = new ObjectInputStream(byteStream))
|
try (ObjectInputStream stream = new ObjectInputStream(byteStream))
|
||||||
@@ -125,7 +131,16 @@ public interface MessageSerializer
|
|||||||
.error("Malformed message, could not get message length.");
|
.error("Malformed message, could not get message length.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
message = new byte[lengthBuffer.getInt()];
|
try
|
||||||
|
{
|
||||||
|
message = new byte[lengthBuffer.getInt()];
|
||||||
|
}
|
||||||
|
catch (NegativeArraySizeException e)
|
||||||
|
{
|
||||||
|
throw new IOException("Invalid array size for message " + Arrays
|
||||||
|
.toString(messageNum)
|
||||||
|
, e);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Writes the message
|
* Writes the message
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user