Reverting changes of LongPollingSystem.
This commit is contained in:
@@ -10,6 +10,4 @@ public interface LongPollableResource {
|
||||
public boolean registerRequest(WaitingRequest waitingRequest);
|
||||
|
||||
public void deregisterRequest(WaitingRequest waitingRequest);
|
||||
|
||||
public void requestWaitingNotification();
|
||||
}
|
||||
|
||||
@@ -66,30 +66,24 @@ public class LongPollingSystem {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
Set<ResourceWaitingRequest> resourcesCopy;
|
||||
synchronized (_waitingActions) {
|
||||
resourcesCopy = new HashSet<ResourceWaitingRequest>(_waitingActions);
|
||||
}
|
||||
Set<ResourceWaitingRequest> resourcesCopy;
|
||||
synchronized (_waitingActions) {
|
||||
resourcesCopy = new HashSet<ResourceWaitingRequest>(_waitingActions);
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
Iterator<ResourceWaitingRequest> iterator = resourcesCopy.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ResourceWaitingRequest waitingRequest = iterator.next();
|
||||
if (waitingRequest.getLongPollingResource().wasProcessed())
|
||||
long now = System.currentTimeMillis();
|
||||
Iterator<ResourceWaitingRequest> iterator = resourcesCopy.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ResourceWaitingRequest waitingRequest = iterator.next();
|
||||
if (waitingRequest.getLongPollingResource().wasProcessed())
|
||||
_waitingActions.remove(waitingRequest);
|
||||
else {
|
||||
if (waitingRequest.getStart() + _pollingLength < now) {
|
||||
waitingRequest.getLongPollableResource().deregisterRequest(waitingRequest);
|
||||
_waitingActions.remove(waitingRequest);
|
||||
else {
|
||||
if (waitingRequest.getStart() + _pollingLength < now) {
|
||||
waitingRequest.getLongPollableResource().deregisterRequest(waitingRequest);
|
||||
_waitingActions.remove(waitingRequest);
|
||||
execute(waitingRequest.getLongPollingResource());
|
||||
} else {
|
||||
waitingRequest.getLongPollableResource().requestWaitingNotification();
|
||||
}
|
||||
execute(waitingRequest.getLongPollingResource());
|
||||
}
|
||||
}
|
||||
} catch (Exception exp) {
|
||||
_log.error("Failure while processing polling requests", exp);
|
||||
}
|
||||
|
||||
pause();
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gempukku.lotro.game.state;
|
||||
import com.gempukku.lotro.common.Token;
|
||||
import com.gempukku.lotro.communication.GameStateListener;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import static com.gempukku.lotro.game.state.GameEvent.Type.*;
|
||||
import com.gempukku.lotro.logic.decisions.AwaitingDecision;
|
||||
import com.gempukku.lotro.logic.timing.GameStats;
|
||||
import com.gempukku.polling.LongPollableResource;
|
||||
@@ -10,8 +11,6 @@ import com.gempukku.polling.WaitingRequest;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.gempukku.lotro.game.state.GameEvent.Type.*;
|
||||
|
||||
public class GameCommunicationChannel implements GameStateListener, LongPollableResource {
|
||||
private List<GameEvent> _events = Collections.synchronizedList(new LinkedList<GameEvent>());
|
||||
private String _self;
|
||||
@@ -50,11 +49,6 @@ public class GameCommunicationChannel implements GameStateListener, LongPollable
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestWaitingNotification() {
|
||||
// Ignore, we do not remove user from it
|
||||
}
|
||||
|
||||
private synchronized void appendEvent(GameEvent event) {
|
||||
_events.add(event);
|
||||
if (_waitingRequest != null) {
|
||||
|
||||
@@ -6,10 +6,10 @@ import com.gempukku.polling.WaitingRequest;
|
||||
|
||||
public class DraftCommunicationChannel implements LongPollableResource {
|
||||
private int _channelNumber;
|
||||
private long _lastAccessed;
|
||||
|
||||
private String _cardChoiceOnClient;
|
||||
private volatile boolean _changed;
|
||||
private volatile long _lastAccessed;
|
||||
private volatile WaitingRequest _waitingRequest;
|
||||
|
||||
public DraftCommunicationChannel(int channelNumber) {
|
||||
@@ -34,7 +34,7 @@ public class DraftCommunicationChannel implements LongPollableResource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean registerRequest(WaitingRequest waitingRequest) {
|
||||
public boolean registerRequest(WaitingRequest waitingRequest) {
|
||||
if (_changed)
|
||||
return true;
|
||||
|
||||
@@ -42,11 +42,6 @@ public class DraftCommunicationChannel implements LongPollableResource {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestWaitingNotification() {
|
||||
updateLastAccess();
|
||||
}
|
||||
|
||||
public synchronized void draftChanged() {
|
||||
_changed = true;
|
||||
if (_waitingRequest != null) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
|
||||
public class ChatCommunicationChannel implements ChatRoomListener, LongPollableResource {
|
||||
private List<ChatMessage> _messages = new LinkedList<ChatMessage>();
|
||||
private volatile long _lastConsumed = System.currentTimeMillis();
|
||||
private long _lastConsumed = System.currentTimeMillis();
|
||||
private volatile WaitingRequest _waitingRequest;
|
||||
|
||||
@Override
|
||||
@@ -27,11 +27,6 @@ public class ChatCommunicationChannel implements ChatRoomListener, LongPollableR
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestWaitingNotification() {
|
||||
updateLastAccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void messageReceived(ChatMessage message) {
|
||||
_messages.add(message);
|
||||
@@ -53,11 +48,11 @@ public class ChatCommunicationChannel implements ChatRoomListener, LongPollableR
|
||||
return _messages.size() > 0;
|
||||
}
|
||||
|
||||
private void updateLastAccess() {
|
||||
private synchronized void updateLastAccess() {
|
||||
_lastConsumed = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public long getLastAccessed() {
|
||||
public synchronized long getLastAccessed() {
|
||||
return _lastConsumed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ import java.util.*;
|
||||
|
||||
public class HallCommunicationChannel implements LongPollableResource {
|
||||
private int _channelNumber;
|
||||
private long _lastConsumed;
|
||||
private String _lastMotd;
|
||||
private Map<String, Map<String, String>> _tournamentQueuePropsOnClient = new LinkedHashMap<String, Map<String, String>>();
|
||||
private Map<String, Map<String, String>> _tournamentPropsOnClient = new LinkedHashMap<String, Map<String, String>>();
|
||||
private Map<String, Map<String, String>> _tablePropsOnClient = new LinkedHashMap<String, Map<String, String>>();
|
||||
private Set<String> _playedGames = new HashSet<String>();
|
||||
private volatile boolean _changed;
|
||||
private volatile long _lastConsumed;
|
||||
private volatile WaitingRequest _waitingRequest;
|
||||
|
||||
public HallCommunicationChannel(int channelNumber) {
|
||||
@@ -37,11 +37,6 @@ public class HallCommunicationChannel implements LongPollableResource {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestWaitingNotification() {
|
||||
updateLastAccess();
|
||||
}
|
||||
|
||||
public synchronized void hallChanged() {
|
||||
_changed = true;
|
||||
if (_waitingRequest != null) {
|
||||
|
||||
Reference in New Issue
Block a user