X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2Fserver%2FServerBridge.java;h=b97699622b3a8e8b0c2325a758c9eb3f5b567eb3;hb=3087aeb5f7b9fffcb57d51030c4674f9768e7f02;hp=cb06f56369054deb8ab06b6a1e201c7ac1611e62;hpb=08f80ac5fa60738d3ad74c4b5390a0b79ae313d4;p=fanfix.git diff --git a/src/be/nikiroo/utils/serial/server/ServerBridge.java b/src/be/nikiroo/utils/serial/server/ServerBridge.java index cb06f56..b976996 100644 --- a/src/be/nikiroo/utils/serial/server/ServerBridge.java +++ b/src/be/nikiroo/utils/serial/server/ServerBridge.java @@ -9,6 +9,7 @@ import java.net.UnknownHostException; import be.nikiroo.utils.StringUtils; import be.nikiroo.utils.TraceHandler; +import be.nikiroo.utils.Version; import be.nikiroo.utils.serial.Importer; /** @@ -127,16 +128,17 @@ public class ServerBridge extends Server { // Bad impl, not up to date (should work, but not efficient) return new ConnectActionServerString(s, key) { @Override - public void action() throws Exception { - onClientContact(); + public void action(Version clientVersion) throws Exception { + onClientContact(clientVersion); final ConnectActionServerString bridge = this; try { new ConnectActionClientString(forwardToHost, forwardToPort, forwardToKey) { @Override - public void action() throws Exception { - onServerContact(); + public void action(Version serverVersion) + throws Exception { + onServerContact(serverVersion); for (String fromClient = bridge.rec(); fromClient != null; fromClient = bridge .rec()) { @@ -165,15 +167,15 @@ public class ServerBridge extends Server { /** * This is the method that is called each time a client contact us. */ - protected void onClientContact() { - getTraceHandler().trace(">>> CLIENT "); + protected void onClientContact(Version clientVersion) { + getTraceHandler().trace(">>> CLIENT " + clientVersion); } /** * This is the method that is called each time a client contact us. */ - protected void onServerContact() { - getTraceHandler().trace("<<< SERVER"); + protected void onServerContact(Version serverVersion) { + getTraceHandler().trace("<<< SERVER " + serverVersion); getTraceHandler().trace(""); } @@ -198,6 +200,13 @@ public class ServerBridge extends Server { trace("<<< SERVER", data); } + @Override + protected ConnectActionClient getConnectionToMe() + throws UnknownHostException, IOException { + return new ConnectActionClientString(new Socket((String) null, + getPort()), key); + } + @Override public void run() { getTraceHandler().trace( @@ -227,14 +236,14 @@ public class ServerBridge extends Server { try { while (data.startsWith("ZIP:") || data.startsWith("B64:")) { if (data.startsWith("ZIP:")) { - data = StringUtils.unbase64s(data.substring(4), true); + data = StringUtils.unzip64s(data.substring(4)); } else if (data.startsWith("B64:")) { - data = StringUtils.unbase64s(data.substring(4), false); + data = StringUtils.unzip64s(data.substring(4)); } } InputStream stream = new ByteArrayInputStream( - data.getBytes("UTF-8")); + StringUtils.getBytes(data)); try { Object obj = new Importer().read(stream).getValue(); if (obj == null) {