Skip to content

Commit 0b62cc0

Browse files
author
Deng
committed
make readline optional and release 1.2.5
1 parent b233e05 commit 0b62cc0

9 files changed

Lines changed: 45 additions & 112 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Step 2. Add the dependency in the form
1717

1818
```gradle
1919
dependencies {
20-
compile 'com.github.vilyever:AndroidSocketClient:1.2.4'
20+
compile 'com.github.vilyever:AndroidSocketClient:1.2.5'
2121
}
2222
```
2323

app/.gitignore

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1 @@
1-
# Built application files
2-
*.apk
3-
*.ap_
4-
5-
# Files for the Dalvik VM
6-
*.dex
7-
8-
# Java class files
9-
*.class
10-
11-
# Generated files
12-
bin/
13-
gen/
14-
15-
# Gradle files
16-
.gradle/
17-
build/
18-
19-
# Local configuration file (sdk path, etc)
20-
local.properties
21-
22-
# Proguard folder generated by Eclipse
23-
proguard/
24-
25-
# Log Files
26-
*.log
27-
28-
# Android Studio Navigation editor temp files
29-
.navigation/
30-
31-
# Android Studio captures folder
32-
captures/
33-
34-
# Android Studio
35-
*.iml
36-
.idea
37-
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
38-
.gradle
39-
build/
40-
41-
# Eclipse project files
42-
.classpath
43-
.project
44-
45-
#NDK
46-
obj/
47-
48-
# OSX files
49-
.DS_Store
50-
51-
# Windows thumbnail db
52-
Thumbs.db
1+
/build

app/app.iml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@
7171
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
7272
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
7373
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
74+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.1.1/jars" />
75+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/jars" />
7476
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
77+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.vilyever/AndroidLogger/1.0.0/jars" />
7578
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
7679
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
7780
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
@@ -86,9 +89,12 @@
8689
</content>
8790
<orderEntry type="jdk" jdkName="Android API 23 Platform (1)" jdkType="Android SDK" />
8891
<orderEntry type="sourceFolder" forTests="false" />
92+
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
93+
<orderEntry type="library" exported="" name="AndroidLogger-1.0.0" level="project" />
8994
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
9095
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
9196
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
97+
<orderEntry type="library" exported="" name="design-23.1.1" level="project" />
9298
<orderEntry type="module" module-name="socketclient" exported="" />
9399
</component>
94100
</module>

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ dependencies {
2424
compile 'com.android.support:appcompat-v7:23.1.1'
2525

2626
compile project(":socketclient")
27+
compile 'com.github.vilyever:AndroidLogger:1.0.0'
2728
}

socketclient/.gitignore

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1 @@
1-
# Built application files
2-
*.apk
3-
*.ap_
4-
5-
# Files for the Dalvik VM
6-
*.dex
7-
8-
# Java class files
9-
*.class
10-
11-
# Generated files
12-
bin/
13-
gen/
14-
15-
# Gradle files
16-
.gradle/
17-
build/
18-
19-
# Local configuration file (sdk path, etc)
20-
local.properties
21-
22-
# Proguard folder generated by Eclipse
23-
proguard/
24-
25-
# Log Files
26-
*.log
27-
28-
# Android Studio Navigation editor temp files
29-
.navigation/
30-
31-
# Android Studio captures folder
32-
captures/
33-
34-
# Android Studio
35-
*.iml
36-
.idea
37-
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
38-
.gradle
39-
build/
40-
41-
# Eclipse project files
42-
.classpath
43-
.project
44-
45-
#NDK
46-
obj/
47-
48-
# OSX files
49-
.DS_Store
50-
51-
# Windows thumbnail db
52-
Thumbs.db
1+
/build

socketclient/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ dependencies {
2222
compile 'com.android.support:appcompat-v7:23.1.1'
2323

2424
compile 'com.github.vilyever:AndroidResource:1.2.0'
25-
compile 'com.github.vilyever:AndroidLogger:1.0.0'
2625
}

socketclient/build_library_ext.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ext {
22
buildVersionName = {
3-
"1.2.4"
3+
"1.2.5"
44
}
55

66
/**

socketclient/socketclient.iml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.id=":socketclient" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.github.vilyever" external.system.module.version="1.2.3" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id=":socketclient" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.github.vilyever" external.system.module.version="1.2.4" type="JAVA_MODULE" version="4">
33
<component name="FacetManager">
44
<facet type="android-gradle" name="Android-Gradle">
55
<configuration>
@@ -83,13 +83,10 @@
8383
</content>
8484
<orderEntry type="jdk" jdkName="Android API 23 Platform (1)" jdkType="Android SDK" />
8585
<orderEntry type="sourceFolder" forTests="false" />
86-
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
87-
<orderEntry type="library" exported="" name="AndroidLogger-1.0.0" level="project" />
8886
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
8987
<orderEntry type="library" exported="" name="AndroidResource-1.2.0" level="project" />
9088
<orderEntry type="library" exported="" name="AndroidContextHolder-1.1.0" level="project" />
9189
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
9290
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
93-
<orderEntry type="library" exported="" name="design-23.1.1" level="project" />
9491
</component>
9592
</module>

socketclient/src/main/java/com/vilyever/socketclient/SocketClient.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ public int getRemotePort() {
193193
return this.remotePort;
194194
}
195195

196+
private boolean supportReadLine;
197+
public SocketClient setSupportReadLine(boolean supportReadLine) {
198+
this.supportReadLine = supportReadLine;
199+
return this;
200+
}
201+
public boolean isSupportReadLine() {
202+
return this.supportReadLine;
203+
}
204+
196205
private int connectionTimeout;
197206
public SocketClient setConnectionTimeout(int connectionTimeout) {
198207
if (connectionTimeout < 0) {
@@ -589,7 +598,30 @@ public void run() {
589598
bufferedReader = new BufferedReader(new InputStreamReader(self.getRunningSocket().getInputStream(), "UTF-8"));
590599

591600
while (self.isConnected() && !isInterrupted()) {
592-
String response = bufferedReader.readLine();
601+
String response = null;
602+
if (self.isSupportReadLine()) {
603+
response = bufferedReader.readLine();
604+
}
605+
else {
606+
StringBuilder stringBuilder = new StringBuilder();
607+
char[] chars = new char[1024 * 4];
608+
int n = 0;
609+
while (-1 != (n = bufferedReader.read(chars, 0, chars.length))) {
610+
// remove cr
611+
while (n > 0 && (chars[n - 1] == '\r' || chars[n - 1] == '\n')) {
612+
n--;
613+
}
614+
615+
stringBuilder.append(chars, 0, n);
616+
617+
// if last read clear the buffer
618+
if (n < chars.length || !bufferedReader.ready()) {
619+
break;
620+
}
621+
}
622+
623+
response = stringBuilder.toString();
624+
}
593625

594626
if (response == null) {
595627
self.disconnect();

0 commit comments

Comments
 (0)