import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.logging.Logger;
/**
* An FCP connection to a Freenet node.
*/
public class FcpConnection {
+ /** Logger. */
+ private static final Logger logger = Logger.getLogger(FcpConnection.class.getName());
+
/** The default port for FCP v2. */
public static final int DEFAULT_PORT = 9481;
if (connectionHandler != null) {
throw new IllegalStateException("already connected, disconnect first");
}
+ logger.info("connecting to " + address + ":" + port + "…");
remoteSocket = new Socket(address, port);
remoteInputStream = remoteSocket.getInputStream();
remoteOutputStream = remoteSocket.getOutputStream();
if (connectionHandler == null) {
return;
}
+ logger.info("disconnecting…");
FcpUtils.close(remoteSocket);
connectionHandler.stop();
connectionHandler = null;
* if an I/O error occurs
*/
public synchronized void sendMessage(FcpMessage fcpMessage) throws IOException {
- System.out.println("sending message: " + fcpMessage.getName());
+ logger.fine("sending message: " + fcpMessage.getName());
fcpMessage.write(remoteOutputStream);
}
* The received message
*/
void handleMessage(FcpMessage fcpMessage) {
+ logger.fine("received message: " + fcpMessage.getName());
String messageName = fcpMessage.getName();
countMessage(messageName);
if ("SimpleProgress".equals(messageName)) {
oldValue = incomingMessageStatistics.get(name);
}
incomingMessageStatistics.put(name, oldValue + 1);
+ logger.finest("count for " + name + ": " + (oldValue + 1));
}
/**