Renaming classes to common name pattern.
This commit is contained in:
@@ -13,8 +13,8 @@ import com.gempukku.lotro.game.LotroServer;
|
||||
import com.gempukku.lotro.game.ParticipantCommunicationVisitor;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
import com.gempukku.lotro.game.state.EventSerializer;
|
||||
import com.gempukku.lotro.game.state.GameCommunicationChannel;
|
||||
import com.gempukku.lotro.game.state.GameEvent;
|
||||
import com.gempukku.lotro.game.state.GatheringParticipantCommunicationChannel;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.handler.codec.http.*;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder;
|
||||
@@ -130,7 +130,7 @@ public class GameRequestHandler extends LotroServerRequestHandler implements Uri
|
||||
Document doc = documentBuilder.newDocument();
|
||||
Element update = doc.createElement("update");
|
||||
|
||||
GatheringParticipantCommunicationChannel communicationChannel = _gameMediator.getCommunicationChannel(_resourceOwner, _channelNumber);
|
||||
GameCommunicationChannel communicationChannel = _gameMediator.getCommunicationChannel(_resourceOwner, _channelNumber);
|
||||
_gameMediator.processVisitor(communicationChannel, _channelNumber, _resourceOwner.getName(), new SerializationVisitor(doc, update));
|
||||
|
||||
doc.appendChild(update);
|
||||
|
||||
@@ -10,13 +10,13 @@ import java.util.*;
|
||||
|
||||
import static com.gempukku.lotro.game.state.GameEvent.Type.*;
|
||||
|
||||
public class GatheringParticipantCommunicationChannel implements GameStateListener {
|
||||
public class GameCommunicationChannel implements GameStateListener {
|
||||
private List<GameEvent> _events = new LinkedList<GameEvent>();
|
||||
private String _self;
|
||||
private long _lastConsumed = System.currentTimeMillis();
|
||||
private int _channelNumber;
|
||||
|
||||
public GatheringParticipantCommunicationChannel(String self, int channelNumber) {
|
||||
public GameCommunicationChannel(String self, int channelNumber) {
|
||||
_self = self;
|
||||
_channelNumber = channelNumber;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.gempukku.lotro.chat;
|
||||
|
||||
import com.gempukku.lotro.PrivateInformationException;
|
||||
import com.gempukku.lotro.SubscriptionExpiredException;
|
||||
import com.gempukku.lotro.game.GatheringChatRoomListener;
|
||||
import com.gempukku.lotro.game.ChatCommunicationChannel;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
@@ -13,7 +13,7 @@ public class ChatRoomMediator {
|
||||
private Logger _logger;
|
||||
private ChatRoom _chatRoom;
|
||||
|
||||
private Map<String, GatheringChatRoomListener> _listeners = new HashMap<String, GatheringChatRoomListener>();
|
||||
private Map<String, ChatCommunicationChannel> _listeners = new HashMap<String, ChatCommunicationChannel>();
|
||||
|
||||
private int _channelInactivityTimeoutPeriod = 1000 * 20; // 10 seconds
|
||||
private Set<String> _allowedPlayers;
|
||||
@@ -37,7 +37,7 @@ public class ChatRoomMediator {
|
||||
if (!admin && _allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||
throw new PrivateInformationException();
|
||||
|
||||
GatheringChatRoomListener value = new GatheringChatRoomListener();
|
||||
ChatCommunicationChannel value = new ChatCommunicationChannel();
|
||||
_listeners.put(playerId, value);
|
||||
_chatRoom.joinChatRoom(playerId, value);
|
||||
return value.consumeMessages();
|
||||
@@ -46,10 +46,10 @@ public class ChatRoomMediator {
|
||||
}
|
||||
}
|
||||
|
||||
public GatheringChatRoomListener getChatRoomListener(String playerId) throws SubscriptionExpiredException {
|
||||
public ChatCommunicationChannel getChatRoomListener(String playerId) throws SubscriptionExpiredException {
|
||||
_lock.readLock().lock();
|
||||
try {
|
||||
GatheringChatRoomListener gatheringChatRoomListener = _listeners.get(playerId);
|
||||
ChatCommunicationChannel gatheringChatRoomListener = _listeners.get(playerId);
|
||||
if (gatheringChatRoomListener == null)
|
||||
throw new SubscriptionExpiredException();
|
||||
return gatheringChatRoomListener;
|
||||
@@ -85,10 +85,10 @@ public class ChatRoomMediator {
|
||||
_lock.writeLock().lock();
|
||||
try {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
Map<String, GatheringChatRoomListener> copy = new HashMap<String, GatheringChatRoomListener>(_listeners);
|
||||
for (Map.Entry<String, GatheringChatRoomListener> playerListener : copy.entrySet()) {
|
||||
Map<String, ChatCommunicationChannel> copy = new HashMap<String, ChatCommunicationChannel>(_listeners);
|
||||
for (Map.Entry<String, ChatCommunicationChannel> playerListener : copy.entrySet()) {
|
||||
String playerId = playerListener.getKey();
|
||||
GatheringChatRoomListener listener = playerListener.getValue();
|
||||
ChatCommunicationChannel listener = playerListener.getValue();
|
||||
if (currentTime > listener.getLastAccessed() + _channelInactivityTimeoutPeriod) {
|
||||
_chatRoom.partChatRoom(playerId);
|
||||
_listeners.remove(playerId);
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.gempukku.lotro.chat.ChatRoomListener;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class GatheringChatRoomListener implements ChatRoomListener {
|
||||
public class ChatCommunicationChannel implements ChatRoomListener {
|
||||
private List<ChatMessage> _messages = new LinkedList<ChatMessage>();
|
||||
private long _lastConsumed = System.currentTimeMillis();
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.gempukku.lotro.game;
|
||||
|
||||
import com.gempukku.lotro.common.ApplicationConfiguration;
|
||||
import com.gempukku.lotro.game.state.EventSerializer;
|
||||
import com.gempukku.lotro.game.state.GameCommunicationChannel;
|
||||
import com.gempukku.lotro.game.state.GameEvent;
|
||||
import com.gempukku.lotro.game.state.GatheringParticipantCommunicationChannel;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
@@ -50,9 +50,9 @@ public class GameRecorder {
|
||||
|
||||
public GameRecordingInProgress recordGame(LotroGameMediator lotroGame, final String formatName, final String tournament, final Map<String, String> deckNames) {
|
||||
final Date startData = new Date();
|
||||
final Map<String, GatheringParticipantCommunicationChannel> recordingChannels = new HashMap<String, GatheringParticipantCommunicationChannel>();
|
||||
final Map<String, GameCommunicationChannel> recordingChannels = new HashMap<String, GameCommunicationChannel>();
|
||||
for (String playerId : lotroGame.getPlayersPlaying()) {
|
||||
GatheringParticipantCommunicationChannel recordChannel = new GatheringParticipantCommunicationChannel(playerId, 0);
|
||||
GameCommunicationChannel recordChannel = new GameCommunicationChannel(playerId, 0);
|
||||
lotroGame.addGameStateListener(playerId, recordChannel);
|
||||
recordingChannels.put(playerId, recordChannel);
|
||||
}
|
||||
@@ -84,9 +84,9 @@ public class GameRecorder {
|
||||
return new DeflaterOutputStream(new FileOutputStream(recordingFile), deflater);
|
||||
}
|
||||
|
||||
private Map<String, String> saveRecordedChannels(Map<String, GatheringParticipantCommunicationChannel> gameProgress) {
|
||||
private Map<String, String> saveRecordedChannels(Map<String, GameCommunicationChannel> gameProgress) {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
for (Map.Entry<String, GatheringParticipantCommunicationChannel> playerRecordings : gameProgress.entrySet()) {
|
||||
for (Map.Entry<String, GameCommunicationChannel> playerRecordings : gameProgress.entrySet()) {
|
||||
String playerId = playerRecordings.getKey();
|
||||
|
||||
String gameRecordingId = getRecordingId(playerId);
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.gempukku.lotro.SubscriptionExpiredException;
|
||||
import com.gempukku.lotro.common.*;
|
||||
import com.gempukku.lotro.communication.GameStateListener;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
import com.gempukku.lotro.game.state.GameCommunicationChannel;
|
||||
import com.gempukku.lotro.game.state.GameEvent;
|
||||
import com.gempukku.lotro.game.state.GatheringParticipantCommunicationChannel;
|
||||
import com.gempukku.lotro.logic.GameUtils;
|
||||
import com.gempukku.lotro.logic.decisions.AwaitingDecision;
|
||||
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
|
||||
@@ -23,7 +23,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
public class LotroGameMediator {
|
||||
private static final Logger LOG = Logger.getLogger(LotroGameMediator.class);
|
||||
|
||||
private Map<String, GatheringParticipantCommunicationChannel> _communicationChannels = new HashMap<String, GatheringParticipantCommunicationChannel>();
|
||||
private Map<String, GameCommunicationChannel> _communicationChannels = new HashMap<String, GameCommunicationChannel>();
|
||||
private DefaultUserFeedback _userFeedback;
|
||||
private DefaultLotroGame _lotroGame;
|
||||
private Map<String, Integer> _playerClocks = new HashMap<String, Integer>();
|
||||
@@ -230,12 +230,12 @@ public class LotroGameMediator {
|
||||
_writeLock.lock();
|
||||
try {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
Map<String, GatheringParticipantCommunicationChannel> channelsCopy = new HashMap<String, GatheringParticipantCommunicationChannel>(_communicationChannels);
|
||||
for (Map.Entry<String, GatheringParticipantCommunicationChannel> playerChannels : channelsCopy.entrySet()) {
|
||||
Map<String, GameCommunicationChannel> channelsCopy = new HashMap<String, GameCommunicationChannel>(_communicationChannels);
|
||||
for (Map.Entry<String, GameCommunicationChannel> playerChannels : channelsCopy.entrySet()) {
|
||||
String playerId = playerChannels.getKey();
|
||||
// Channel is stale (user no longer connected to game, to save memory, we remove the channel
|
||||
// User can always reconnect and establish a new channel
|
||||
GatheringParticipantCommunicationChannel channel = playerChannels.getValue();
|
||||
GameCommunicationChannel channel = playerChannels.getValue();
|
||||
if (currentTime > channel.getLastAccessed() + _playerDecisionTimeoutPeriod) {
|
||||
_lotroGame.removeGameStateListener(channel);
|
||||
_communicationChannels.remove(playerId);
|
||||
@@ -296,7 +296,7 @@ public class LotroGameMediator {
|
||||
String playerName = player.getName();
|
||||
_writeLock.lock();
|
||||
try {
|
||||
GatheringParticipantCommunicationChannel communicationChannel = _communicationChannels.get(playerName);
|
||||
GameCommunicationChannel communicationChannel = _communicationChannels.get(playerName);
|
||||
if (communicationChannel != null) {
|
||||
if (communicationChannel.getChannelNumber() == channelNumber) {
|
||||
AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(playerName);
|
||||
@@ -333,14 +333,14 @@ public class LotroGameMediator {
|
||||
}
|
||||
}
|
||||
|
||||
public GatheringParticipantCommunicationChannel getCommunicationChannel(Player player, int channelNumber) throws PrivateInformationException, SubscriptionConflictException, SubscriptionExpiredException {
|
||||
public GameCommunicationChannel getCommunicationChannel(Player player, int channelNumber) throws PrivateInformationException, SubscriptionConflictException, SubscriptionExpiredException {
|
||||
String playerName = player.getName();
|
||||
if (!player.getType().contains("a") && !_allowSpectators && !_playersPlaying.contains(playerName))
|
||||
throw new PrivateInformationException();
|
||||
|
||||
_readLock.lock();
|
||||
try {
|
||||
GatheringParticipantCommunicationChannel communicationChannel = _communicationChannels.get(playerName);
|
||||
GameCommunicationChannel communicationChannel = _communicationChannels.get(playerName);
|
||||
if (communicationChannel != null) {
|
||||
if (communicationChannel.getChannelNumber() == channelNumber) {
|
||||
return communicationChannel;
|
||||
@@ -355,7 +355,7 @@ public class LotroGameMediator {
|
||||
}
|
||||
}
|
||||
|
||||
public void processVisitor(GatheringParticipantCommunicationChannel communicationChannel, int channelNumber, String playerName, ParticipantCommunicationVisitor visitor) {
|
||||
public void processVisitor(GameCommunicationChannel communicationChannel, int channelNumber, String playerName, ParticipantCommunicationVisitor visitor) {
|
||||
visitor.visitChannelNumber(channelNumber);
|
||||
for (GameEvent gameEvent : communicationChannel.consumeGameEvents())
|
||||
visitor.visitGameEvent(gameEvent);
|
||||
@@ -382,7 +382,7 @@ public class LotroGameMediator {
|
||||
int number = _channelNextIndex;
|
||||
_channelNextIndex++;
|
||||
|
||||
GatheringParticipantCommunicationChannel participantCommunicationChannel = new GatheringParticipantCommunicationChannel(playerName, number);
|
||||
GameCommunicationChannel participantCommunicationChannel = new GameCommunicationChannel(playerName, number);
|
||||
_communicationChannels.put(playerName, participantCommunicationChannel);
|
||||
|
||||
_lotroGame.addGameStateListener(playerName, participantCommunicationChannel);
|
||||
|
||||
Reference in New Issue
Block a user