diff --git a/KdeConnect/src/main/java/org/kde/connect/ComputerLinks/TcpComputerLink.java b/KdeConnect/src/main/java/org/kde/connect/ComputerLinks/TcpComputerLink.java index bf1fd5e3..91885fad 100644 --- a/KdeConnect/src/main/java/org/kde/connect/ComputerLinks/TcpComputerLink.java +++ b/KdeConnect/src/main/java/org/kde/connect/ComputerLinks/TcpComputerLink.java @@ -27,8 +27,10 @@ public class TcpComputerLink extends BaseComputerLink { super(linkProvider); sChannel = SocketChannel.open(); - sChannel.connect(new InetSocketAddress(ip, port)); + sChannel.socket().setSoTimeout(0); + sChannel.socket().setKeepAlive(true); sChannel.configureBlocking(false); + sChannel.connect(new InetSocketAddress(ip, port)); } @@ -112,7 +114,7 @@ public class TcpComputerLink extends BaseComputerLink { ByteBuffer buffer = ByteBuffer.allocate(4096); int read = sChannel.read(buffer); - //TODO: Check if there is more to read (or we have read more than one package) + //TODO: Check if there is more to read (or otherwise if we have read more than one package) String s = new String( buffer.array(), 0, read, charset ); Log.e("readable","Read "+read+" bytes: "+s); diff --git a/KdeConnect/src/main/java/org/kde/connect/LinkProviders/AvahiTcpLinkProvider.java b/KdeConnect/src/main/java/org/kde/connect/LinkProviders/AvahiTcpLinkProvider.java index b61dbd0f..360e6325 100644 --- a/KdeConnect/src/main/java/org/kde/connect/LinkProviders/AvahiTcpLinkProvider.java +++ b/KdeConnect/src/main/java/org/kde/connect/LinkProviders/AvahiTcpLinkProvider.java @@ -71,6 +71,10 @@ public class AvahiTcpLinkProvider implements BaseLinkProvider { link.setDeviceId(id); link.sendPackage(NetworkPackage.createIdentityPackage(ctx)); + if (visibleComputers.containsKey(host)) { + //Remove old connection to same host, probably down + cr.onConnectionLost(visibleComputers.get(host)); + } visibleComputers.put(host,link); cr.onConnectionAccepted(id,name,link); diff --git a/KdeConnect/src/main/java/org/kde/connect/PackageInterfaces/ClipboardPackageInterface.java b/KdeConnect/src/main/java/org/kde/connect/PackageInterfaces/ClipboardPackageInterface.java index 1c63b101..1e6017fa 100644 --- a/KdeConnect/src/main/java/org/kde/connect/PackageInterfaces/ClipboardPackageInterface.java +++ b/KdeConnect/src/main/java/org/kde/connect/PackageInterfaces/ClipboardPackageInterface.java @@ -43,5 +43,4 @@ public class ClipboardPackageInterface extends BasePackageInterface { cm.setText(np.getString("content")); } } - } diff --git a/KdeConnect/src/main/res/layout/activity_main.xml b/KdeConnect/src/main/res/layout/activity_main.xml index 64b806b0..0afd3477 100644 --- a/KdeConnect/src/main/res/layout/activity_main.xml +++ b/KdeConnect/src/main/res/layout/activity_main.xml @@ -17,6 +17,15 @@ + android:id="@+id/listView1" + android:layout_weight="1"/> + +