forked from ajanata/PretendYoureXyzzy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add user client information to user metrics info (language, device cl…
…ass, name). Add metrics logging for server start up, user disconnect, and card judging events.
- Loading branch information
Showing
16 changed files
with
252 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
/** | ||
* Copyright (c) 2012, Andy Janata | ||
* Copyright (c) 2012-2017, Andy Janata | ||
* All rights reserved. | ||
* | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, are permitted | ||
* provided that the following conditions are met: | ||
* | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
* and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above copyright notice, this list of | ||
* conditions and the following disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
|
@@ -30,15 +30,15 @@ | |
|
||
/** | ||
* Wrap around an {@code HttpServletRequest}, to allow parameters to be retrieved by enum value. | ||
* | ||
* | ||
* @author Andy Janata ([email protected]) | ||
*/ | ||
public class RequestWrapper { | ||
private final HttpServletRequest request; | ||
|
||
/** | ||
* Create a new RequestWrapper. | ||
* | ||
* | ||
* @param request | ||
* An {@code HttpServletRequest} to wrap around. | ||
*/ | ||
|
@@ -48,7 +48,7 @@ public RequestWrapper(final HttpServletRequest request) { | |
|
||
/** | ||
* Returns the value of a request parameter as a String, or null if the parameter does not exist. | ||
* | ||
* | ||
* @param parameter | ||
* Parameter to get. | ||
* @return Value of parameter, or null if parameter does not exist. | ||
|
@@ -57,6 +57,18 @@ public String getParameter(final AjaxRequest parameter) { | |
return request.getParameter(parameter.toString()); | ||
} | ||
|
||
/** | ||
* Returns the value of a request header as a String, or {@code null} if the header does not | ||
* exist. | ||
* | ||
* @param header | ||
* Header to get. | ||
* @return Value of header, or {@code null} if header does not exist. | ||
*/ | ||
public String getHeader(final String header) { | ||
return request.getHeader(header); | ||
} | ||
|
||
/** | ||
* If there is an {@code X-Forwarded-For} header, the <strong>first</strong> entry in that list | ||
* is returned instead. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
/** | ||
* Copyright (c) 2012, Andy Janata | ||
* Copyright (c) 2012-2017, Andy Janata | ||
* All rights reserved. | ||
* | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, are permitted | ||
* provided that the following conditions are met: | ||
* | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
* and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above copyright notice, this list of | ||
* conditions and the following disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
|
@@ -25,20 +25,19 @@ | |
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import net.socialgamer.cah.data.WhiteCard; | ||
|
||
|
||
/** | ||
* Class to track which card(s) have been played by players. Can get the card(s) for a player, and | ||
* also which player played a given card. | ||
* | ||
* | ||
* All methods in this class are synchronized. | ||
* | ||
* | ||
* @author Andy Janata ([email protected]) | ||
*/ | ||
public class PlayerPlayedCardsTracker { | ||
|
@@ -53,7 +52,7 @@ public class PlayerPlayedCardsTracker { | |
|
||
/** | ||
* Add a played card to the mappings. | ||
* | ||
* | ||
* @param player | ||
* Player which played the card. | ||
* @param card | ||
|
@@ -71,7 +70,7 @@ public synchronized void addCard(final Player player, final WhiteCard card) { | |
|
||
/** | ||
* Get the {@code Player} that played a card, given the card's ID. | ||
* | ||
* | ||
* @param id | ||
* Card ID to check. | ||
* @return The {@code Player} that played the card. | ||
|
@@ -82,7 +81,7 @@ public synchronized Player getPlayerForId(final int id) { | |
|
||
/** | ||
* Determine whether a player has played any cards this round. | ||
* | ||
* | ||
* @param player | ||
* Player to check. | ||
* @return True if the player has played any cards this round. | ||
|
@@ -102,7 +101,7 @@ public synchronized List<WhiteCard> getCards(final Player player) { | |
|
||
/** | ||
* Remove and return a player's cards from the played cards tracking. | ||
* | ||
* | ||
* @param player | ||
* Player to remove. | ||
* @return The cards the player had played, or {@code null} if the player had not played cards. | ||
|
@@ -143,4 +142,16 @@ public synchronized void clear() { | |
public synchronized Collection<List<WhiteCard>> cards() { | ||
return playerCardMap.values(); | ||
} | ||
|
||
/** | ||
* @return A {@code Map} of users to a {@code List} of the cards they played. | ||
*/ | ||
public synchronized Map<User, List<WhiteCard>> cardsByUser() { | ||
final Map<User, List<WhiteCard>> cardsByUser = new HashMap<>(); | ||
// TODO java8: streams | ||
for (final Map.Entry<Player, List<WhiteCard>> entry : playerCardMap.entrySet()) { | ||
cardsByUser.put(entry.getKey().getUser(), entry.getValue()); | ||
} | ||
return Collections.unmodifiableMap(cardsByUser); | ||
} | ||
} |
Oops, something went wrong.