mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Reduce initial connection bandwidth (#1200)
Reduces bandwidth requirements by being much lazier about how much calibration data is sent to the UI.
This commit is contained in:
@@ -350,8 +350,7 @@ public class DataSocketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMessage(Object message, WsContext user) throws JsonProcessingException {
|
||||
ByteBuffer b = ByteBuffer.wrap(objectMapper.writeValueAsBytes(message));
|
||||
private void sendMessage(ByteBuffer b, WsContext user) throws JsonProcessingException {
|
||||
if (user.session.isOpen()) {
|
||||
user.send(b);
|
||||
}
|
||||
@@ -359,16 +358,18 @@ public class DataSocketHandler {
|
||||
|
||||
public void broadcastMessage(Object message, WsContext userToSkip)
|
||||
throws JsonProcessingException {
|
||||
ByteBuffer b = ByteBuffer.wrap(objectMapper.writeValueAsBytes(message));
|
||||
|
||||
if (userToSkip == null) {
|
||||
for (WsContext user : users) {
|
||||
sendMessage(message, user);
|
||||
sendMessage(b, user);
|
||||
}
|
||||
} else {
|
||||
var skipUserPort = ((InetSocketAddress) userToSkip.session.getRemoteAddress()).getPort();
|
||||
for (WsContext user : users) {
|
||||
var userPort = ((InetSocketAddress) user.session.getRemoteAddress()).getPort();
|
||||
if (userPort != skipUserPort) {
|
||||
sendMessage(message, user);
|
||||
sendMessage(b, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user