-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathissue.txt
28 lines (24 loc) · 952 Bytes
/
issue.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
https://github.com/openwebnet/rx-openwebnet/pull/9/files
https://github.com/dendeps/rx-openwebnet/commit/9b1b2de70060dfc9d45fb3ae1ced11c873b407e5
# lib/src/main/java/com/github/niqdev/openwebnet/OpenWebNetObservable.java
```
static Func1<OpenContext, Observable<String>> read() {
return context -> {
try {
ByteBuffer buffer = context.getEmptyBuffer();
SocketChannel channel = context.getClient();
Integer count = 1;
String message = "";
while(count >0 && !message.contains(ACK)) {
int length = message.length();
count = channel.read(buffer);
message = new String(buffer.array()).trim();
log(String.format("read: %d|%s", count, message.substring(length)));
}
return Observable.just(message);
} catch (IOException e) {
return Observable.error(e);
}
};
}
```