import be.nikiroo.utils.StringUtils;
import be.nikiroo.utils.TraceHandler;
+import be.nikiroo.utils.Version;
import be.nikiroo.utils.serial.Importer;
/**
// 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()) {
/**
* 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("");
}
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(
* the data to trace
*/
private void trace(String prefix, String data) {
- // TODO: we convert to string and back
int size = data == null ? 0 : data.length();
String ssize = StringUtils.formatNumber(size) + "bytes";