a somewhat more robust way of closing and reconnecting to Igtimi WebSocket servers;

ignore the onWebSocketClose event if it is caused by the reconnect() call

Change-Id: I0b735d17168855e66ade684f5953a1faaa8e82e4
This commit is contained in:
Axel Uhl committed 2016-07-06 16:50:17 +02:00
1 parent b5b74b8982
commit b884ad9677
2 files changed
+76 -43

No files matched your search

@@ -248,13 +248,15 @@ public abstract class WindStatusServlet extends SailingServerHttpServlet impleme
@Override
public void windDataReceived(Wind wind, String deviceSerialNumber) {
Deque<IgtimiMessageInfo> messagesPerDevice = lastIgtimiMessages.get(deviceSerialNumber);
if(messagesPerDevice == null) {
if (messagesPerDevice == null) {
messagesPerDevice = new ArrayDeque<IgtimiMessageInfo>(NUMBER_OF_MESSAGES_PER_DEVICE_TO_SHOW);
lastIgtimiMessages.put(deviceSerialNumber, messagesPerDevice);
}
messagesPerDevice.addFirst(new IgtimiMessageInfo(wind));
if(messagesPerDevice.size() > NUMBER_OF_MESSAGES_PER_DEVICE_TO_SHOW) {
messagesPerDevice.pollLast();
synchronized (messagesPerDevice) {
messagesPerDevice.addFirst(new IgtimiMessageInfo(wind));
if (messagesPerDevice.size() > NUMBER_OF_MESSAGES_PER_DEVICE_TO_SHOW) {
messagesPerDevice.pollLast();
}
}
}