Working on the new polling.

This commit is contained in:
marcins78
2013-01-18 18:37:39 +00:00
parent ca24378de4
commit ac08f02ee7
6 changed files with 14 additions and 17 deletions

View File

@@ -61,18 +61,18 @@ public class ChatRequestHandler extends LotroServerRequestHandler implements Uri
throw new HttpProcessingException(404);
try {
if (message != null && message.trim().length() > 0)
if (message != null && message.trim().length() > 0) {
chatRoom.sendMessage(resourceOwner.getName(), StringEscapeUtils.escapeHtml(message), resourceOwner.getType().contains("a"));
} catch (PrivateInformationException exp) {
throw new HttpProcessingException(403);
}
try {
ChatCommunicationChannel pollableResource = chatRoom.getChatRoomListener(resourceOwner.getName());
ChatUpdateLongPollingResource polledResource = new ChatUpdateLongPollingResource(chatRoom, room, resourceOwner.getName(), responseWriter);
_longPollingSystem.processLongPollingResource(polledResource, pollableResource);
responseWriter.writeXmlResponse(null);
} else {
ChatCommunicationChannel pollableResource = chatRoom.getChatRoomListener(resourceOwner.getName());
ChatUpdateLongPollingResource polledResource = new ChatUpdateLongPollingResource(chatRoom, room, resourceOwner.getName(), responseWriter);
_longPollingSystem.processLongPollingResource(polledResource, pollableResource);
}
} catch (SubscriptionExpiredException exp) {
responseWriter.writeError(410);
} catch (PrivateInformationException exp) {
throw new HttpProcessingException(403);
}
}

View File

@@ -240,9 +240,7 @@ var ChatBoxUI = Class.extend({
sendMessage:function (message) {
var that = this;
this.communication.sendChatMessage(this.name, message, function(xml) {
that.processMessages(xml, false);
}, this.chatErrorMap());
this.communication.sendChatMessage(this.name, message, this.chatErrorMap());
},
chatMalfunction: function() {

View File

@@ -473,7 +473,7 @@ var GempLotrCommunication = Class.extend({
dataType:"xml"
});
},
sendChatMessage:function (room, messages, callback, errorMap) {
sendChatMessage:function (room, messages, errorMap) {
$.ajax({
type:"POST",
url:this.url + "/chat/" + room,
@@ -482,7 +482,6 @@ var GempLotrCommunication = Class.extend({
data:{
participantId:getUrlParam("participantId"),
message:messages},
success:callback,
traditional:true,
error:this.errorCheck(errorMap),
dataType:"xml"

View File

@@ -9,7 +9,7 @@ public class LongPollingSystem {
private static Logger _log = Logger.getLogger(LongPollingSystem.class);
private ConcurrentLinkedQueue<TimeoutResource> _waitingActions = new ConcurrentLinkedQueue<TimeoutResource>();
private long _pollingInterval = 200;
private long _pollingInterval = 1000;
private long _pollingLength = 10000;
private ProcessingRunnable _processingRunnable;

View File

@@ -15,7 +15,7 @@ public class ChatRoomMediator {
private Map<String, ChatCommunicationChannel> _listeners = new HashMap<String, ChatCommunicationChannel>();
private int _channelInactivityTimeoutPeriod = 1000 * 20; // 10 seconds
private final int _channelInactivityTimeoutPeriod;
private Set<String> _allowedPlayers;
private ReadWriteLock _lock = new ReentrantReadWriteLock();

View File

@@ -74,7 +74,7 @@ public class HallServer extends AbstractServer {
_collectionsManager = collectionsManager;
_tournamentPrizeSchemeRegistry = tournamentPrizeSchemeRegistry;
_pairingMechanismRegistry = pairingMechanismRegistry;
_hallChat = _chatServer.createChatRoom("Game Hall", true, 10);
_hallChat = _chatServer.createChatRoom("Game Hall", true, 15);
_tournamentQueues.put("fotr_queue", new ImmediateRecurringQueue(635, "fotr_block",
CollectionType.ALL_CARDS, "fotrQueue-", "Fellowship Block", 8,