Giving direct access to HallCommunicationChannel.

This commit is contained in:
marcins78
2013-01-18 15:56:52 +00:00
parent afd9cd2353
commit d97ef2aa44
2 changed files with 4 additions and 22 deletions

View File

@@ -445,7 +445,7 @@ public class HallRequestHandler extends LotroServerRequestHandler implements Uri
@Override
public boolean isChanged() {
try {
return _hallServer.hasChanges(_resourceOwner, _channelNumber);
return _hallServer.getCommunicationChannel(_resourceOwner, _channelNumber).hasChangesInCommunicationChannel(_hallServer, _resourceOwner);
} catch (SubscriptionExpiredException e) {
return true;
} catch (SubscriptionConflictException e) {
@@ -463,7 +463,7 @@ public class HallRequestHandler extends LotroServerRequestHandler implements Uri
Element hall = doc.createElement("hall");
try {
_hallServer.processHall(_resourceOwner, _channelNumber, new SerializeHallInfoVisitor(doc, hall));
_hallServer.getCommunicationChannel(_resourceOwner, _channelNumber).processCommunicationChannel(_hallServer, _resourceOwner, new SerializeHallInfoVisitor(doc, hall));
} catch (SubscriptionExpiredException exp) {
throw new HttpProcessingException(410);
} catch (SubscriptionConflictException exp) {

View File

@@ -432,31 +432,13 @@ public class HallServer extends AbstractServer {
}
}
public boolean hasChanges(Player player, int channelNumber) throws SubscriptionExpiredException, SubscriptionConflictException {
public HallCommunicationChannel getCommunicationChannel(Player player, int channelNumber) throws SubscriptionExpiredException, SubscriptionConflictException {
_hallDataAccessLock.readLock().lock();
try {
HallCommunicationChannel communicationChannel = _playerChannelCommunication.get(player);
if (communicationChannel != null) {
if (communicationChannel.getChannelNumber() == channelNumber) {
return communicationChannel.hasChangesInCommunicationChannel(this, player);
} else {
throw new SubscriptionConflictException();
}
} else {
throw new SubscriptionExpiredException();
}
} finally {
_hallDataAccessLock.readLock().unlock();
}
}
public void processHall(Player player, int channelNumber, HallChannelVisitor hallChannelVisitor) throws SubscriptionExpiredException, SubscriptionConflictException {
_hallDataAccessLock.readLock().lock();
try {
HallCommunicationChannel communicationChannel = _playerChannelCommunication.get(player);
if (communicationChannel != null) {
if (communicationChannel.getChannelNumber() == channelNumber) {
communicationChannel.processCommunicationChannel(this, player, hallChannelVisitor);
return communicationChannel;
} else {
throw new SubscriptionConflictException();
}