2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 05:37:43 +00:00

Some bugs fixed and sockets keepalive enabled

This commit is contained in:
Albert Vaca 2013-07-23 20:22:38 +02:00
parent 91ebceb5ca
commit 43059d0230
4 changed files with 18 additions and 4 deletions

View File

@ -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);

View File

@ -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);

View File

@ -43,5 +43,4 @@ public class ClipboardPackageInterface extends BasePackageInterface {
cm.setText(np.getString("content"));
}
}
}

View File

@ -17,6 +17,15 @@
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/listView1"/>
android:id="@+id/listView1"
android:layout_weight="1"/>
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/editText"
android:layout_gravity="left|center_vertical"
android:layout_weight="1"
android:text="I'm a test text field"/>
</LinearLayout>