From efca4a844debbafecba62655b0232fcae76ec9e0 Mon Sep 17 00:00:00 2001 From: codybum Date: Thu, 11 Apr 2024 15:19:43 -0400 Subject: [PATCH] updates a many, including time outs and seq numbers --- .../java/io/cresco/wsapi/websockets/APIDataPlane.java | 10 ++++++++-- .../io/cresco/wsapi/websockets/APILogStreamer.java | 1 + .../java/io/cresco/wsapi/websockets/APISocket.java | 1 + .../java/io/cresco/wsapi/websockets/EventSocket.java | 1 + .../java/io/cresco/wsapi/websockets/LogSocket.java | 1 + .../io/cresco/wsapi/websockets/LogStreamerNew.java | 1 + 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/cresco/wsapi/websockets/APIDataPlane.java b/src/main/java/io/cresco/wsapi/websockets/APIDataPlane.java index a20d1ac..2002007 100644 --- a/src/main/java/io/cresco/wsapi/websockets/APIDataPlane.java +++ b/src/main/java/io/cresco/wsapi/websockets/APIDataPlane.java @@ -53,7 +53,7 @@ public APIDataPlane() { @OnOpen public void onWebSocketConnect(Session sess) { - + sess.setMaxIdleTimeout(0); sess.setMaxBinaryMessageBufferSize(1024 * 1024 * 1024); sess.setMaxTextMessageBufferSize(1024 * 1024 * 1024); @@ -223,11 +223,17 @@ public void onMessage(Message msg) { } else if (msg instanceof BytesMessage) { String transferId = msg.getStringProperty("transfer_id"); - //logger.error("INCOMING TRANSFER ID: " + transferId); + + + String seqNum = String.format("%1$" + 6 + "s", msg.getStringProperty("seq_num")).replace(' ', '0'); + //logger.error("INCOMING TRANSFER ID: " + transferId + " seq: " + msg.getStringProperty("seq_num")); //System.out.println("onMessage(Message msg) transferId: " + transferId); long dataSize = ((BytesMessage) msg).getBodyLength(); byte[] bytes = new byte[(int)dataSize]; ((BytesMessage) msg).readBytes(bytes); + if(msg.getStringProperty("seq_num") != null) { + bytes = Bytes.concat(seqNum.getBytes(), bytes); + } if(transferId != null) { bytes = Bytes.concat(transferId.getBytes(), bytes); } diff --git a/src/main/java/io/cresco/wsapi/websockets/APILogStreamer.java b/src/main/java/io/cresco/wsapi/websockets/APILogStreamer.java index 80d79d4..000c765 100644 --- a/src/main/java/io/cresco/wsapi/websockets/APILogStreamer.java +++ b/src/main/java/io/cresco/wsapi/websockets/APILogStreamer.java @@ -41,6 +41,7 @@ public APILogStreamer() { @OnOpen public void onWebSocketConnect(Session sess) { + sess.setMaxIdleTimeout(0); sessions.add(sess); String logSessionId = UUID.randomUUID().toString(); sessionMap.put(sess.getId(),logSessionId); diff --git a/src/main/java/io/cresco/wsapi/websockets/APISocket.java b/src/main/java/io/cresco/wsapi/websockets/APISocket.java index 287b900..a94d47a 100644 --- a/src/main/java/io/cresco/wsapi/websockets/APISocket.java +++ b/src/main/java/io/cresco/wsapi/websockets/APISocket.java @@ -40,6 +40,7 @@ public APISocket() { @OnOpen public void onWebSocketConnect(Session sess) { + sess.setMaxIdleTimeout(0); sess.setMaxBinaryMessageBufferSize(1024 * 1024 * 1024); sess.setMaxTextMessageBufferSize(1024 * 1024 * 1024); sessions.add(sess); diff --git a/src/main/java/io/cresco/wsapi/websockets/EventSocket.java b/src/main/java/io/cresco/wsapi/websockets/EventSocket.java index 65a68a8..080bd14 100644 --- a/src/main/java/io/cresco/wsapi/websockets/EventSocket.java +++ b/src/main/java/io/cresco/wsapi/websockets/EventSocket.java @@ -22,6 +22,7 @@ public class EventSocket @OnOpen public void onWebSocketConnect(Session sess) { + sess.setMaxIdleTimeout(0); sessions.add(sess); //System.out.println("Socket Connected: " + sess); diff --git a/src/main/java/io/cresco/wsapi/websockets/LogSocket.java b/src/main/java/io/cresco/wsapi/websockets/LogSocket.java index dfc1f6a..e345977 100644 --- a/src/main/java/io/cresco/wsapi/websockets/LogSocket.java +++ b/src/main/java/io/cresco/wsapi/websockets/LogSocket.java @@ -38,6 +38,7 @@ public LogSocket() { @OnOpen public void onWebSocketConnect(Session sess) { + sess.setMaxIdleTimeout(0); sessions.add(sess); String logSessionId = UUID.randomUUID().toString(); sessionMap.put(sess.getId(),logSessionId); diff --git a/src/main/java/io/cresco/wsapi/websockets/LogStreamerNew.java b/src/main/java/io/cresco/wsapi/websockets/LogStreamerNew.java index ccefff8..ce62a5b 100644 --- a/src/main/java/io/cresco/wsapi/websockets/LogStreamerNew.java +++ b/src/main/java/io/cresco/wsapi/websockets/LogStreamerNew.java @@ -38,6 +38,7 @@ public LogStreamerNew() { @OnOpen public void onWebSocketConnect(Session sess) { + sess.setMaxIdleTimeout(0); sessions.add(sess); //System.out.println("Socket Connected: " + sess);