Better handling of long requests, channels are notified of waiting request every tick (1s) so that it should not timeout due to it.
This commit is contained in:
@@ -10,4 +10,6 @@ public interface LongPollableResource {
|
||||
public boolean registerRequest(WaitingRequest waitingRequest);
|
||||
|
||||
public void deregisterRequest(WaitingRequest waitingRequest);
|
||||
|
||||
public void requestWaitingNotification();
|
||||
}
|
||||
|
||||
@@ -82,6 +82,8 @@ public class LongPollingSystem {
|
||||
waitingRequest.getLongPollableResource().deregisterRequest(waitingRequest);
|
||||
_waitingActions.remove(waitingRequest);
|
||||
execute(waitingRequest.getLongPollingResource());
|
||||
} else {
|
||||
waitingRequest.getLongPollableResource().requestWaitingNotification();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ 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;
|
||||
@@ -11,6 +10,8 @@ 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;
|
||||
@@ -49,6 +50,11 @@ 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) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class DraftCommunicationChannel implements LongPollableResource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerRequest(WaitingRequest waitingRequest) {
|
||||
public synchronized boolean registerRequest(WaitingRequest waitingRequest) {
|
||||
if (_changed)
|
||||
return true;
|
||||
|
||||
@@ -42,6 +42,11 @@ public class DraftCommunicationChannel implements LongPollableResource {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void requestWaitingNotification() {
|
||||
updateLastAccess();
|
||||
}
|
||||
|
||||
public synchronized void draftChanged() {
|
||||
_changed = true;
|
||||
if (_waitingRequest != null) {
|
||||
|
||||
@@ -27,6 +27,11 @@ public class ChatCommunicationChannel implements ChatRoomListener, LongPollableR
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void requestWaitingNotification() {
|
||||
updateLastAccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void messageReceived(ChatMessage message) {
|
||||
_messages.add(message);
|
||||
|
||||
@@ -37,6 +37,11 @@ public class HallCommunicationChannel implements LongPollableResource {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void requestWaitingNotification() {
|
||||
updateLastAccess();
|
||||
}
|
||||
|
||||
public synchronized void hallChanged() {
|
||||
_changed = true;
|
||||
if (_waitingRequest != null) {
|
||||
|
||||
Reference in New Issue
Block a user