From c835336e61b48bee69e71ad138601130bc81ba1e Mon Sep 17 00:00:00 2001 From: Christian 'ketura' McCarty Date: Wed, 24 Aug 2022 01:05:25 -0500 Subject: [PATCH] Added support for user-defined table descriptions --- .../async/handler/HallRequestHandler.java | 64 ++++++++++--------- .../gemp-lotr-async/src/main/web/hall.html | 3 +- .../src/main/web/js/gemp-022/communication.js | 3 +- .../src/main/web/js/gemp-022/hallUi.js | 18 ++++-- .../com/gempukku/lotro/hall/GameSettings.java | 7 +- .../lotro/hall/HallCommunicationChannel.java | 3 +- .../gempukku/lotro/hall/HallInfoVisitor.java | 2 +- .../com/gempukku/lotro/hall/HallServer.java | 14 ++-- .../com/gempukku/lotro/hall/TableHolder.java | 6 +- 9 files changed, 69 insertions(+), 51 deletions(-) diff --git a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/HallRequestHandler.java b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/HallRequestHandler.java index ece5c779a..39e2dc7bc 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/HallRequestHandler.java +++ b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/HallRequestHandler.java @@ -125,30 +125,32 @@ public class HallRequestHandler extends LotroServerRequestHandler implements Uri private void createTable(HttpRequest request, ResponseWriter responseWriter) throws Exception { HttpPostRequestDecoder postDecoder = new HttpPostRequestDecoder(request); try { - String participantId = getFormParameterSafely(postDecoder, "participantId"); - String format = getFormParameterSafely(postDecoder, "format"); - String deckName = getFormParameterSafely(postDecoder, "deckName"); - String timer = getFormParameterSafely(postDecoder, "timer"); + String participantId = getFormParameterSafely(postDecoder, "participantId"); + String format = getFormParameterSafely(postDecoder, "format"); + String deckName = getFormParameterSafely(postDecoder, "deckName"); + String timer = getFormParameterSafely(postDecoder, "timer"); + String desc = getFormParameterSafely(postDecoder, "desc"); - Player resourceOwner = getResourceOwnerSafely(request, participantId); + Player resourceOwner = getResourceOwnerSafely(request, participantId); - try { - _hallServer.createNewTable(format, resourceOwner, deckName, timer); - responseWriter.writeXmlResponse(null); - } catch (HallException e) { - try - { - //try again assuming it's a new player with one of the default library decks selected - Player librarian = _playerDao.getPlayer("Librarian"); - _hallServer.spoofNewTable(format, resourceOwner, librarian, deckName, timer); + try { + _hallServer.createNewTable(format, resourceOwner, deckName, timer, desc); responseWriter.writeXmlResponse(null); - } catch (HallException ex) { - } + catch (HallException e) { + try + { + //try again assuming it's a new player with one of the default library decks selected + Player librarian = _playerDao.getPlayer("Librarian"); + _hallServer.spoofNewTable(format, resourceOwner, librarian, deckName, timer, "(New Player) " + desc); + responseWriter.writeXmlResponse(null); + } + catch (HallException ex) { } responseWriter.writeXmlResponse(marshalException(e)); + } } - } finally { + finally { postDecoder.destroy(); } } @@ -347,21 +349,23 @@ public class HallRequestHandler extends LotroServerRequestHandler implements Uri private void updateHall(HttpRequest request, ResponseWriter responseWriter) throws Exception { HttpPostRequestDecoder postDecoder = new HttpPostRequestDecoder(request); try { - String participantId = getFormParameterSafely(postDecoder, "participantId"); - int channelNumber = Integer.parseInt(getFormParameterSafely(postDecoder, "channelNumber")); + String participantId = getFormParameterSafely(postDecoder, "participantId"); + int channelNumber = Integer.parseInt(getFormParameterSafely(postDecoder, "channelNumber")); - Player resourceOwner = getResourceOwnerSafely(request, participantId); - processLoginReward(resourceOwner.getName()); + Player resourceOwner = getResourceOwnerSafely(request, participantId); + processLoginReward(resourceOwner.getName()); - try { - HallCommunicationChannel pollableResource = _hallServer.getCommunicationChannel(resourceOwner, channelNumber); - HallUpdateLongPollingResource polledResource = new HallUpdateLongPollingResource(pollableResource, request, resourceOwner, responseWriter); - longPollingSystem.processLongPollingResource(polledResource, pollableResource); - } catch (SubscriptionExpiredException exp) { - responseWriter.writeError(410); - } catch (SubscriptionConflictException exp) { - responseWriter.writeError(409); - } + try { + HallCommunicationChannel pollableResource = _hallServer.getCommunicationChannel(resourceOwner, channelNumber); + HallUpdateLongPollingResource polledResource = new HallUpdateLongPollingResource(pollableResource, request, resourceOwner, responseWriter); + longPollingSystem.processLongPollingResource(polledResource, pollableResource); + } + catch (SubscriptionExpiredException exp) { + responseWriter.writeError(410); + } + catch (SubscriptionConflictException exp) { + responseWriter.writeError(409); + } } finally { postDecoder.destroy(); } diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/hall.html b/gemp-lotr/gemp-lotr-async/src/main/web/hall.html index 4bf0e62b2..035110364 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/hall.html +++ b/gemp-lotr/gemp-lotr-async/src/main/web/hall.html @@ -162,7 +162,7 @@
  • - Server Stats + Server Info
  • @@ -286,6 +286,7 @@ | +