ConnectionData.java
1.4 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* // Copyright 2022-2023 by zhaoming
*/
// connection data act as a bridge between different threads pools
package websocketsrv;
import com.k2fsa.sherpa.onnx.OnlineStream;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.*;
import org.java_websocket.WebSocket;
public class ConnectionData {
private WebSocket webSocket; // the websocket for this connection data
private OnlineStream stream; // connection stream
private Queue<float[]> queueSamples =
new LinkedList<float[]>(); // binary data rec from the client
private boolean eof = false; // connection data is done
private LocalDateTime lastHandleTime; // used for time out in ms
public ConnectionData(WebSocket webSocket, OnlineStream stream) {
this.webSocket = webSocket;
this.stream = stream;
}
public void addSamplesToData(float[] samples) {
this.queueSamples.add(samples);
}
public LocalDateTime getLastHandleTime() {
return this.lastHandleTime;
}
public void setLastHandleTime(LocalDateTime now) {
this.lastHandleTime = now;
}
public boolean getEof() {
return this.eof;
}
public void setEof(boolean eof) {
this.eof = eof;
}
public WebSocket getWebSocket() {
return this.webSocket;
}
public Queue<float[]> getQueueSamples() {
return this.queueSamples;
}
public OnlineStream getStream() {
return this.stream;
}
}