Skip to content

Commit 6acece9

Browse files
author
Aaron
committed
New DSTransport
1 parent 562446a commit 6acece9

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ subprojects {
55
apply plugin: 'maven'
66

77
group 'org.iot-dsa'
8-
version '0.53.0'
8+
version '0.53.1a2'
99

1010
sourceCompatibility = 1.8
1111
targetCompatibility = 1.8

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/io/DSByteBuffer.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public void print(PrintStream out, int cols) {
8383
}
8484

8585
/**
86-
* /**
8786
* Gets the bytes from the given buffer, which will be flipped, then cleared.
8887
*/
8988
public DSByteBuffer put(ByteBuffer buf) {
@@ -412,9 +411,7 @@ public DSByteBuffer putU32(long v, boolean bigEndian) {
412411
(byte) (v >>> 24));
413412
}
414413

415-
/**
416-
* Returns the next byte in the buffer, or -1 when nothing is available.
417-
*/
414+
@Override
418415
public int read() {
419416
if (length == 0) {
420417
return -1;
@@ -425,6 +422,11 @@ public int read() {
425422
return ret;
426423
}
427424

425+
@Override
426+
public int read(byte[] buf, int off, int len) {
427+
return sendTo(buf, off, len);
428+
}
429+
428430
/**
429431
* Overwrites byte in the internal buffer.
430432
*

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/transport/DSTransport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,12 @@ public void write(byte[] buf, int off, int len, boolean isLast) {
289289
traceOut = new StringBuilder();
290290
traceOut.append("Send:\n");
291291
}
292+
int idx = off;
292293
for (int i = 0; i < len; i++) {
293294
if (traceOutCols > 0) {
294295
traceOut.append(' ');
295296
}
296-
DSBytes.toHex(buf[i], traceIn);
297+
DSBytes.toHex(buf[idx++], traceOut);
297298
if (++traceOutCols == HEX_COLS) {
298299
traceOutCols = 0;
299300
traceOut.append('\n');

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/transport/DSTransportWs.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,16 @@
33
import com.acuity.iot.dsa.dslink.io.DSByteBuffer;
44
import com.acuity.iot.dsa.dslink.io.DSCharBuffer;
55
import com.acuity.iot.dsa.dslink.io.DSIoException;
6-
import com.acuity.iot.dsa.dslink.sys.cert.SysCertService;
76
import java.io.IOException;
87
import java.io.UncheckedIOException;
9-
import java.net.URI;
108
import java.nio.ByteBuffer;
119
import javax.websocket.CloseReason;
12-
import javax.websocket.ContainerProvider;
1310
import javax.websocket.OnClose;
1411
import javax.websocket.OnError;
1512
import javax.websocket.OnMessage;
1613
import javax.websocket.OnOpen;
1714
import javax.websocket.RemoteEndpoint;
1815
import javax.websocket.Session;
19-
import javax.websocket.WebSocketContainer;
20-
import org.iot.dsa.util.DSException;
2116

2217
/**
2318
* Abstract websocket transport.
@@ -163,7 +158,7 @@ protected void doWrite(byte[] buf, int off, int len, boolean isLast) {
163158
byteBuffer.put(buf, off, len);
164159
}
165160
try {
166-
if (isLast) {
161+
if (isLast && (byteBuffer.position() > 0)) {
167162
byteBuffer.flip();
168163
basicRemote.sendBinary(byteBuffer, isLast);
169164
byteBuffer.clear();

0 commit comments

Comments
 (0)