}
private Message logMessage(BufferStream stream, boolean fromClient) {
try {
stream.beginTransaction();
MessageType type = MessageType.getMessageType(stream);
Message message = type.createMessage(stream, fromClient);
if (logFile != null) {
logFile.write((fromClient ? "fromJS ** " : "toJS ** ") + message.toString() + "\n");
} else {
Console.get().info((fromClient ? "fromJS ** " : "toJS ** ") + message.toString());
}