Giving direct access to GatheringChatRoomListener.
This commit is contained in:
@@ -89,7 +89,7 @@ public class ChatRequestHandler extends LotroServerRequestHandler implements Uri
|
||||
@Override
|
||||
public boolean isChanged() {
|
||||
try {
|
||||
return _chatRoom.hasPendingMessages(_playerId);
|
||||
return _chatRoom.getChatRoomListener(_playerId).hasMessages();
|
||||
} catch (SubscriptionExpiredException e) {
|
||||
return true;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class ChatRequestHandler extends LotroServerRequestHandler implements Uri
|
||||
@Override
|
||||
public void process() {
|
||||
try {
|
||||
List<ChatMessage> chatMessages = _chatRoom.getPendingMessages(_playerId);
|
||||
List<ChatMessage> chatMessages = _chatRoom.getChatRoomListener(_playerId).consumeMessages();
|
||||
|
||||
Collection<String> usersInRoom = _chatRoom.getUsersInRoom();
|
||||
|
||||
|
||||
@@ -46,25 +46,13 @@ public class ChatRoomMediator {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPendingMessages(String playerId) throws SubscriptionExpiredException {
|
||||
public GatheringChatRoomListener getChatRoomListener(String playerId) throws SubscriptionExpiredException {
|
||||
_lock.readLock().lock();
|
||||
try {
|
||||
GatheringChatRoomListener gatheringChatRoomListener = _listeners.get(playerId);
|
||||
if (gatheringChatRoomListener == null)
|
||||
throw new SubscriptionExpiredException();
|
||||
return gatheringChatRoomListener.hasMessages();
|
||||
} finally {
|
||||
_lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public List<ChatMessage> getPendingMessages(String playerId) throws SubscriptionExpiredException {
|
||||
_lock.readLock().lock();
|
||||
try {
|
||||
GatheringChatRoomListener gatheringChatRoomListener = _listeners.get(playerId);
|
||||
if (gatheringChatRoomListener == null)
|
||||
throw new SubscriptionExpiredException();
|
||||
return gatheringChatRoomListener.consumeMessages();
|
||||
return gatheringChatRoomListener;
|
||||
} finally {
|
||||
_lock.readLock().unlock();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class GatheringChatRoomListener implements ChatRoomListener {
|
||||
return _messages.size()>0;
|
||||
}
|
||||
|
||||
private void updateLastAccess() {
|
||||
private synchronized void updateLastAccess() {
|
||||
_lastConsumed = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user