You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(149) |
Nov
(38) |
Dec
(4) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(54) |
Feb
(80) |
Mar
(29) |
Apr
(22) |
May
(16) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
| 2005 |
Jan
|
Feb
(10) |
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(19) |
| 2006 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
(15) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(24) |
Dec
(3) |
| 2007 |
Jan
|
Feb
(5) |
Mar
(22) |
Apr
(34) |
May
(22) |
Jun
(5) |
Jul
(12) |
Aug
(1) |
Sep
(7) |
Oct
(13) |
Nov
(49) |
Dec
(171) |
| 2008 |
Jan
(268) |
Feb
(64) |
Mar
(18) |
Apr
(3) |
May
(10) |
Jun
(4) |
Jul
(8) |
Aug
(51) |
Sep
(60) |
Oct
(61) |
Nov
(47) |
Dec
(29) |
| 2009 |
Jan
(10) |
Feb
(138) |
Mar
(254) |
Apr
(230) |
May
(153) |
Jun
(141) |
Jul
(43) |
Aug
(50) |
Sep
(36) |
Oct
(55) |
Nov
(21) |
Dec
(19) |
| 2010 |
Jan
(48) |
Feb
(65) |
Mar
(37) |
Apr
(30) |
May
(31) |
Jun
(20) |
Jul
(37) |
Aug
(9) |
Sep
(14) |
Oct
|
Nov
|
Dec
(37) |
| 2011 |
Jan
(21) |
Feb
(18) |
Mar
(18) |
Apr
(2) |
May
(1) |
Jun
(1) |
Jul
(9) |
Aug
(10) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2012 |
Jan
(23) |
Feb
(49) |
Mar
(60) |
Apr
(9) |
May
(3) |
Jun
|
Jul
(7) |
Aug
(9) |
Sep
|
Oct
(8) |
Nov
(18) |
Dec
(71) |
| 2013 |
Jan
|
Feb
(12) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(11) |
Aug
(1) |
Sep
(8) |
Oct
(29) |
Nov
(7) |
Dec
(1) |
| 2015 |
Jan
|
Feb
(4) |
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Jeff M. <jef...@gm...> - 2019-06-08 22:24:46
|
Hi. Resending without the screenshot to get past need for moderator approval. It's been a long time since I logged into the webclient. I am on a Win 10 64-bit machine. I am using Colossus.jnlp to start. It says it timed out possibly because of a blocked port 26766. Can you help me? Thanks. Jeff Matthews ATTORNEY AT LAW P. O. Box 982 Katy, Texas 77492 (281) 772-0772 |
|
From: Jeff M. <jef...@gm...> - 2019-06-08 22:20:45
|
Hi. It's been a long time since I logged into the webclient. I am on a Win 10 64-bit machine. I am using Colossus.jnlp to start. It says it timed out possibly because of a blocked port. Can you help me? Thanks. Jeff Matthews ATTORNEY AT LAW P. O. Box 982 Katy, Texas 77492 (281) 772-0772 |
|
From: <cl...@us...> - 2015-04-09 19:15:39
|
Revision: 5376
http://sourceforge.net/p/colossus/code/5376
Author: cleka
Date: 2015-04-09 19:15:30 +0000 (Thu, 09 Apr 2015)
Log Message:
-----------
Added controls for 'Need lord for battle control' in WebClient
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/GameTableModel.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/WebClient.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/WebClientSocketThread.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/GameInfo.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IWebServer.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/WebServer.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/WebServerClient.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/GameTableModel.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/GameTableModel.java 2015-04-09 16:48:13 UTC (rev 5375)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/GameTableModel.java 2015-04-09 19:15:30 UTC (rev 5376)
@@ -11,14 +11,15 @@
import javax.swing.table.AbstractTableModel;
import net.sf.colossus.webcommon.GameInfo;
+import net.sf.colossus.webcommon.GameInfo.GameState;
import net.sf.colossus.webcommon.User;
-import net.sf.colossus.webcommon.GameInfo.GameState;
public class GameTableModel extends AbstractTableModel
{
private final String[] columnNames = { "#", "state", "by", "when",
- "duration", "info", "Variant", "Viewmode", "Expire", "Mull", "Towers",
+ "duration", "info", "Variant", "Viewmode", "Expire", "Options",
+ "(dummy)",
"min", "target", "max", "actual", "players", "online" };
private final Vector<GameInfo> data = new Vector<GameInfo>(17, 1);
@@ -108,11 +109,11 @@
break;
case 9:
- o = Boolean.valueOf(gi.getUnlimitedMulligans());
+ o = gi.getOptionsFlagsString();
break;
case 10:
- o = Boolean.valueOf(gi.getBalancedTowers());
+ o = new String("dummy");
break;
case 11:
@@ -163,7 +164,8 @@
case 9:
case 10:
- c = Boolean.class;
+ // c = Boolean.class;
+ c = String.class;
break;
case 11:
@@ -277,6 +279,11 @@
fireTableCellUpdated(row, col);
}
+ public String getOptionsTooltipText(int row)
+ {
+ return data.get(row).GetOptionsTooltipText();
+ }
+
public int addGame(GameInfo gi)
{
int nextIndex = data.size();
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/WebClient.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/WebClient.java 2015-04-09 16:48:13 UTC (rev 5375)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/WebClient.java 2015-04-09 19:15:30 UTC (rev 5376)
@@ -75,11 +75,11 @@
import net.sf.colossus.util.ViableEntityManager;
import net.sf.colossus.webclient.WebClientSocketThread.WcstException;
import net.sf.colossus.webcommon.GameInfo;
+import net.sf.colossus.webcommon.GameInfo.GameState;
import net.sf.colossus.webcommon.IGameRunner;
import net.sf.colossus.webcommon.IWebClient;
import net.sf.colossus.webcommon.IWebServer;
import net.sf.colossus.webcommon.User;
-import net.sf.colossus.webcommon.GameInfo.GameState;
/**
@@ -102,8 +102,9 @@
public final static int WC_VERSION_GENERAL_MESSAGE = 1;
public final static int WC_VERSION_SUPPORTS_PING = 2;
public final static int WC_VERSION_DINO_OK = 3;
+ public final static int WC_VERSION_SUPPORTS_EXTRA_OPTIONS = 4;
- final static int WEB_CLIENT_VERSION = WC_VERSION_DINO_OK;
+ final static int WEB_CLIENT_VERSION = WC_VERSION_SUPPORTS_EXTRA_OPTIONS;
// TODO make this all based on Locale.getDefault()
// Initially: use German. To make it variable, need also to set
@@ -231,6 +232,7 @@
private JCheckBox unlimitedMulligansCB;
private JCheckBox balancedTowersCB;
+ private JCheckBox lordBattleControlCB;
private JLabel nowDateAndTimeLabel;
private JTextField atDateField;
@@ -1170,6 +1172,10 @@
case 5:
case 6:
case 7:
+ case 9:
+ tip = proposedGameDataModel
+ .getOptionsTooltipText(rowIndex);
+ break;
case 15:
tip = "" + getValueAt(rowIndex, colIndex);
break;
@@ -1379,8 +1385,10 @@
preferencesPane.add(new JLabel("Events expire after (turns):"));
preferencesPane.add(eventExpiringBox);
- // checkboxes (unlimited mulligans and balanced tower):
- Box checkboxPane = new Box(BoxLayout.X_AXIS);
+ // checkboxes (unlimited mulligans, balanced tower,
+ // and battlecontrol needs lord):
+ JPanel checkboxPane = new JPanel(new GridLayout(2, 2));
+
boolean unlimitedMulligans = options
.getOption(Options.unlimitedMulligans);
unlimitedMulligansCB = new JCheckBox(Options.unlimitedMulligans,
@@ -1406,9 +1414,24 @@
}
});
+ boolean lordBattleControl = options
+ .getOption(Options.autoSansLordBattles);
+ lordBattleControlCB = new JCheckBox(Options.autoSansLordBattles,
+ lordBattleControl);
+ lordBattleControlCB.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ options.setOption(Options.autoSansLordBattles,
+ lordBattleControlCB.isSelected());
+ }
+ });
+
checkboxPane.add(unlimitedMulligansCB);
checkboxPane.add(balancedTowersCB);
+ checkboxPane.add(lordBattleControlCB);
+
preferencesPane.add(new JLabel("Various settings:"));
preferencesPane.add(checkboxPane);
@@ -2702,11 +2725,11 @@
}
private void do_proposeGame(String variant, String viewmode, long startAt,
- int duration, String summary, String expire, boolean unlimMulli,
- boolean balTowers, int min, int target, int max)
+ int duration, String summary, String expire,
+ List<String> extraOptions, String dummy, int min, int target, int max)
{
server.proposeGame(username, variant, viewmode, startAt, duration,
- summary, expire, unlimMulli, balTowers, min, target, max);
+ summary, expire, extraOptions, dummy, min, target, max);
}
private long getStartTime()
@@ -3716,16 +3739,31 @@
int min = ((Integer)spinner1.getValue()).intValue();
int target = ((Integer)spinner2.getValue()).intValue();
int max = ((Integer)spinner3.getValue()).intValue();
+ List<String> extraOptions = new ArrayList<String>();
+ if (lordBattleControlCB.isSelected())
+ {
+ extraOptions.add(Options.autoSansLordBattles);
+ }
+ if (unlimitedMulligansCB.isSelected())
+ {
+ extraOptions.add(Options.unlimitedMulligans);
+ }
+ if (balancedTowersCB.isSelected())
+ {
+ extraOptions.add(Options.balancedTowers);
+ }
+ String dummy = new String("");
+
boolean scheduled = getScheduledGamesMode();
long startAt = scheduled ? getStartTime() : -1;
int duration = getDuration();
String summaryText = getSummaryText();
+
do_proposeGame(variantBox.getSelectedItem().toString(), viewmodeBox
.getSelectedItem().toString(), startAt, duration, summaryText,
- eventExpiringBox.getSelectedItem().toString(),
- unlimitedMulligansCB.isSelected(), balancedTowersCB.isSelected(),
- min, target, max);
+ eventExpiringBox.getSelectedItem().toString(), extraOptions,
+ dummy, min, target, max);
}
}
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/WebClientSocketThread.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/WebClientSocketThread.java 2015-04-09 16:48:13 UTC (rev 5375)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webclient/WebClientSocketThread.java 2015-04-09 19:15:30 UTC (rev 5376)
@@ -15,9 +15,11 @@
import java.nio.charset.Charset;
import java.util.Date;
import java.util.HashMap;
+import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
+import net.sf.colossus.util.Glob;
import net.sf.colossus.webcommon.GameInfo;
import net.sf.colossus.webcommon.IWebClient;
import net.sf.colossus.webcommon.IWebServer;
@@ -190,6 +192,7 @@
}
}
+
private void connect() throws WcstException
{
String info = null;
@@ -202,8 +205,9 @@
socket.connect(address, 10000);
if (socket != null)
{
- out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
- socket.getOutputStream(), charset)), true);
+ out = new PrintWriter(
+ new BufferedWriter(new OutputStreamWriter(
+ socket.getOutputStream(), charset)), true);
}
else
{
@@ -259,8 +263,8 @@
try
{
- this.in = new BufferedReader(new InputStreamReader(socket
- .getInputStream(), charset));
+ this.in = new BufferedReader(new InputStreamReader(
+ socket.getInputStream(), charset));
send(RegisterUser + sep + username + sep + password + sep + email);
String fromServer = null;
@@ -315,8 +319,8 @@
try
{
- this.in = new BufferedReader(new InputStreamReader(socket
- .getInputStream(), charset));
+ this.in = new BufferedReader(new InputStreamReader(
+ socket.getInputStream(), charset));
send(ConfirmRegistration + sep + username + sep + confCode);
String fromServer = null;
@@ -366,8 +370,8 @@
try
{
- this.in = new BufferedReader(new InputStreamReader(socket
- .getInputStream(), charset));
+ this.in = new BufferedReader(new InputStreamReader(
+ socket.getInputStream(), charset));
int version = webClient.getClientVersion();
send(Login + sep + username + sep + password + sep + force + sep
@@ -776,13 +780,14 @@
public GameInfo proposeGame(String initiator, String variant,
String viewmode, long startAt, int duration, String summary,
- String expire, boolean unlimitedMulligans, boolean balancedTowers,
+ String expire, List<String> extraOptions, String dummy,
int min, int target, int max)
{
+ String optionsString = Glob.glob(extraOptions);
send(Propose + sep + initiator + sep + variant + sep + viewmode + sep
+ startAt + sep + duration + sep + summary + sep + expire + sep
- + unlimitedMulligans + sep + balancedTowers + sep + min + sep
- + target + sep + max);
+ + optionsString + sep + dummy + sep + min + sep + target + sep
+ + max);
return null;
}
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/GameInfo.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/GameInfo.java 2015-04-09 16:48:13 UTC (rev 5375)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/GameInfo.java 2015-04-09 19:15:30 UTC (rev 5376)
@@ -5,11 +5,14 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.colossus.common.Constants;
import net.sf.colossus.common.Options;
+import net.sf.colossus.util.Glob;
+import net.sf.colossus.util.Split;
import net.sf.colossus.webclient.WebClient;
@@ -57,6 +60,7 @@
private String eventExpiring;
private boolean unlimitedMulligans;
private boolean balancedTowers;
+ private boolean autoSansLordBattles;
private int min;
private int target;
@@ -113,17 +117,18 @@
public GameInfo(String initiator, String variant, String viewmode,
long startTime, int duration, String summary, String expire,
- boolean unlimitedMulligans, boolean balancedTowers, int min,
- int target, int max)
+ List<String> extraOptions, String dummy, int min, int target, int max)
{
this(makeTypeFromStarttime(startTime));
+ parseExtraOptions(extraOptions);
+
+ // just to get rid of "unused" warning:
+ LOGGER.finest("Dummy: value of dummy string is '" + dummy + "'.");
this.initiator = initiator;
this.variant = variant;
this.viewmode = viewmode;
this.eventExpiring = expire;
- this.unlimitedMulligans = unlimitedMulligans;
- this.balancedTowers = balancedTowers;
this.min = min;
this.target = target;
this.max = max;
@@ -143,6 +148,35 @@
// System.out.println("NEW GameInfo server side, " + this.toString());
}
+ /*
+ * go through list containing the extraOptions, set the corresponding
+ * boolean values to true
+ */
+ private void parseExtraOptions(List<String> extraOptions)
+ {
+ for (Iterator iterator = extraOptions.iterator(); iterator.hasNext();)
+ {
+ String string = (String)iterator.next();
+ if (string.equals(Options.autoSansLordBattles))
+ {
+ this.autoSansLordBattles = true;
+ }
+ else if (string.equals(Options.unlimitedMulligans))
+ {
+ this.unlimitedMulligans = true;
+ }
+ else if (string.equals(Options.balancedTowers))
+ {
+ this.balancedTowers = true;
+ }
+ else
+ {
+ LOGGER.severe("Unexpected option string '" + string
+ + "' when parsing extraOptions !");
+ }
+ }
+ }
+
// ================= now the stuff for the client side ===============
// used on client side, to restore a proposed game sent by server
@@ -196,8 +230,21 @@
gi.duration = Integer.parseInt(tokens[j++]);
gi.summary = tokens[j++];
gi.eventExpiring = tokens[j++];
- gi.unlimitedMulligans = Boolean.valueOf(tokens[j++]).booleanValue();
- gi.balancedTowers = Boolean.valueOf(tokens[j++]).booleanValue();
+ String token8 = tokens[j++];
+ String token9 = tokens[j++];
+
+ if (token8.equalsIgnoreCase("true")
+ || token8.equalsIgnoreCase("false"))
+ {
+ gi.unlimitedMulligans = Boolean.valueOf(token8).booleanValue();
+ gi.balancedTowers = Boolean.valueOf(token9).booleanValue();
+ }
+ else
+ {
+ List<String> extraOptions = Split.split(Glob.sep, token8);
+ gi.parseExtraOptions(extraOptions);
+ }
+
gi.min = Integer.parseInt(tokens[j++]);
gi.target = Integer.parseInt(tokens[j++]);
gi.max = Integer.parseInt(tokens[j++]);
@@ -220,7 +267,7 @@
return gi;
}
- public String toString(String sep)
+ public String toStringLegacy(String sep)
{
StringBuilder playerList = new StringBuilder();
Iterator<User> it = players.iterator();
@@ -231,9 +278,15 @@
playerList.append(user.getName());
}
+ String summary2 = summary;
+ if (this.autoSansLordBattles)
+ {
+ summary2 = "NOTE! Extra option 'Needs lord for battle control' set! | "
+ + summary;
+ }
String message = gameId + sep + type.toString() + sep
+ state.toString() + sep + initiator + sep + variant + sep
- + viewmode + sep + startTime + sep + duration + sep + summary
+ + viewmode + sep + startTime + sep + duration + sep + summary2
+ sep + eventExpiring + sep + unlimitedMulligans + sep
+ balancedTowers + sep + min + sep + target + sep + max + sep
+ onlineCount + sep + enrolledPlayers + playerList.toString();
@@ -241,6 +294,55 @@
return message;
}
+ public String toString(String sep)
+ {
+ StringBuilder playerList = new StringBuilder();
+ Iterator<User> it = players.iterator();
+ while (it.hasNext())
+ {
+ playerList.append(sep);
+ User user = it.next();
+ playerList.append(user.getName());
+ }
+
+ String message = gameId + sep + type.toString() + sep
+ + state.toString() + sep + initiator + sep + variant + sep
+ + viewmode + sep + startTime + sep + duration + sep + summary
+ + sep + eventExpiring + sep + getExtraOptionsAsString() + sep
+ + new String("dummy") + sep + min + sep + target + sep + max + sep
+ + onlineCount + sep + enrolledPlayers + playerList.toString();
+
+ return message;
+ }
+
+ public String getExtraOptionsAsString()
+ {
+ return Glob.glob(getExtraOptions());
+ }
+
+ public List<String> getExtraOptions()
+ {
+ List<String> extraOptions = new ArrayList<String>();
+
+ if (this.autoSansLordBattles)
+ {
+ extraOptions.add(Options.autoSansLordBattles);
+ }
+
+ if (this.unlimitedMulligans)
+ {
+ this.unlimitedMulligans = true;
+ extraOptions.add(Options.unlimitedMulligans);
+ }
+
+ if (this.balancedTowers)
+ {
+ extraOptions.add(Options.balancedTowers);
+ }
+
+ return extraOptions;
+ }
+
public void setState(GameState state)
{
this.state = state;
@@ -397,6 +499,38 @@
balancedTowers = val;
}
+ public boolean getAutoSansLordBattles()
+ {
+ return autoSansLordBattles;
+ }
+
+ public String getOptionsFlagsString()
+ {
+ String s = (this.unlimitedMulligans ? "U" : "-")
+ + (this.balancedTowers ? "B" : "-")
+ + (this.autoSansLordBattles ? "N" : "-");
+ return s;
+ }
+
+ public String GetOptionsTooltipText()
+ {
+ String ttText = (this.unlimitedMulligans ? Options.unlimitedMulligans
+ : "-")
+ + ", "
+ + (this.balancedTowers ? Options.balancedTowers : "-")
+ + ", "
+ + (this.autoSansLordBattles ? Options.autoSansLordBattles : "-");
+ return ttText;
+
+ }
+
+ public void setAutoSansLordBattles(boolean val)
+ {
+ autoSansLordBattles = val;
+ }
+
+
+
/**
* Have enough players enrolled (at least "min")
* @return true or false whether enough (at least 'min') players are
@@ -685,6 +819,8 @@
gameOptions.setOption(Options.unlimitedMulligans,
getUnlimitedMulligans());
gameOptions.setOption(Options.balancedTowers, getBalancedTowers());
+ gameOptions.setOption(Options.autoSansLordBattles,
+ getAutoSansLordBattles());
// gameOptions.setOption(Options.autoQuit, true);
String name;
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IWebServer.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IWebServer.java 2015-04-09 16:48:13 UTC (rev 5375)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IWebServer.java 2015-04-09 19:15:30 UTC (rev 5376)
@@ -1,6 +1,9 @@
package net.sf.colossus.webcommon;
+import java.util.List;
+
+
/**
* Interface for what WebClient sends to WebServer
*
@@ -47,7 +50,7 @@
// that return value (internally) when used in server side.
public GameInfo proposeGame(String initiator, String variant,
String viewmode, long startAt, int duration, String summary,
- String expire, boolean unlimMulli, boolean balTowers, int min,
+ String expire, List<String> extraOptions, String unUsed, int min,
int target, int max);
public void enrollUserToGame(String gameId, String username);
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/WebServer.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/WebServer.java 2015-04-09 16:48:13 UTC (rev 5375)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/WebServer.java 2015-04-09 19:15:30 UTC (rev 5376)
@@ -21,6 +21,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
@@ -30,6 +31,7 @@
import net.sf.colossus.webclient.WebClient;
import net.sf.colossus.webcommon.FormatWhen;
import net.sf.colossus.webcommon.GameInfo;
+import net.sf.colossus.webcommon.GameInfo.GameState;
import net.sf.colossus.webcommon.IColossusMail;
import net.sf.colossus.webcommon.IGameRunner;
import net.sf.colossus.webcommon.IPortProvider;
@@ -38,7 +40,6 @@
import net.sf.colossus.webcommon.IWebServer;
import net.sf.colossus.webcommon.User;
import net.sf.colossus.webcommon.UserDB;
-import net.sf.colossus.webcommon.GameInfo.GameState;
/**
@@ -732,7 +733,7 @@
public GameInfo proposeGame(String initiator, String variant,
String viewmode, long startAt, int duration, String summary,
- String expire, boolean unlimitedMulligans, boolean balancedTowers,
+ String expire, List<String> extraOptions, String dummy,
int min, int target, int max)
{
if (GameInfo.wouldBeInstantGame(startAt))
@@ -756,8 +757,7 @@
}
GameInfo gi = new GameInfo(initiator, variant, viewmode, startAt,
- duration, summary, expire, unlimitedMulligans, balancedTowers,
- min, target, max);
+ duration, summary, expire, extraOptions, dummy, min, target, max);
String scheduleType = gi.isScheduledGame() ? "scheduled" : "instant";
LOGGER.info("Game " + gi.getGameId() + " (" + scheduleType
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/WebServerClient.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/WebServerClient.java 2015-04-09 16:48:13 UTC (rev 5375)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/WebServerClient.java 2015-04-09 19:15:30 UTC (rev 5376)
@@ -8,6 +8,9 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import net.sf.colossus.common.Options;
+import net.sf.colossus.util.Glob;
+import net.sf.colossus.util.Split;
import net.sf.colossus.webclient.WebClient;
import net.sf.colossus.webcommon.GameInfo;
import net.sf.colossus.webcommon.IWebClient;
@@ -355,6 +358,7 @@
else if (command.equals(IWebServer.Propose))
{
+
String initiator = tokens[1];
String variant = tokens[2];
String viewmode = tokens[3];
@@ -362,14 +366,34 @@
int duration = Integer.parseInt(tokens[5]);
String summary = tokens[6];
String expire = tokens[7];
- boolean unlMullis = Boolean.valueOf(tokens[8]).booleanValue();
- boolean balTowers = Boolean.valueOf(tokens[9]).booleanValue();
int nmin = Integer.parseInt(tokens[10]);
int ntarget = Integer.parseInt(tokens[11]);
int nmax = Integer.parseInt(tokens[12]);
+ List<String> extraOptions = new ArrayList<String>();
+ String dummyString = new String("");
+
+ if (getClientVersion() >= WebClient.WC_VERSION_SUPPORTS_EXTRA_OPTIONS)
+ {
+ String optionsString = tokens[8];
+ dummyString = tokens[9];
+ extraOptions.addAll(Split.split(Glob.sep, optionsString));
+ }
+ else
+ {
+ // earlier arg 8+9 were mulligans and tower options booleans
+ if (Boolean.valueOf(tokens[8]).booleanValue())
+ {
+ extraOptions.add(Options.unlimitedMulligans);
+ }
+ if (Boolean.valueOf(tokens[9]).booleanValue())
+ {
+ extraOptions.add(Options.balancedTowers);
+ }
+ }
+
gi = server.proposeGame(initiator, variant, viewmode, startAt,
- duration, summary, expire, unlMullis, balTowers, nmin,
+ duration, summary, expire, extraOptions, dummyString, nmin,
ntarget, nmax);
}
@@ -863,7 +887,17 @@
public void gameInfo(GameInfo gi)
{
- sendToClient(gameInfo + sep + gi.toString(sep));
+ if (getClientVersion() >= WebClient.WC_VERSION_SUPPORTS_EXTRA_OPTIONS)
+ {
+ LOGGER.info("Sending LegacyGameInfo to client " + getUsername());
+ sendToClient(gameInfo + sep + gi.toString(sep));
+ }
+ else
+ {
+ LOGGER.info("Sending GameInfo (new style) to client "
+ + getUsername());
+ sendToClient(gameInfo + sep + gi.toStringLegacy(sep));
+ }
}
public void gameStartsSoon(String gameId, String byUser)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2015-04-09 16:48:17
|
Revision: 5375
http://sourceforge.net/p/colossus/code/5375
Author: cleka
Date: 2015-04-09 16:48:13 +0000 (Thu, 09 Apr 2015)
Log Message:
-----------
Set eol-style native on all files in webserver related packages
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/ChatMessage.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/FormatWhen.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IManagedGame.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IPortProvider.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/UserDB.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ChatChannel.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ChatMsgStorage.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ClientWatchDog.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ColossusRegistry.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/GameManager.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/QueuedSocketWriter.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/RoundtripTimeBookkeeper.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/WebServerClient.java
Property Changed:
----------------
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/ChatMessage.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/FormatWhen.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IManagedGame.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IPortProvider.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/UserDB.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ChatChannel.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ChatMsgStorage.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ClientWatchDog.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ColossusRegistry.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/GameManager.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/QueuedSocketWriter.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/RoundtripTimeBookkeeper.java
trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/WebServerClient.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/ChatMessage.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/ChatMessage.java 2015-04-09 16:14:41 UTC (rev 5374)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/ChatMessage.java 2015-04-09 16:48:13 UTC (rev 5375)
@@ -1,44 +1,44 @@
-/**
- *
- */
-package net.sf.colossus.webcommon;
-
-
-public class ChatMessage
-{
- String chatId;
- long when;
- String sender;
- String message;
-
- public ChatMessage(String chatId, long when, String sender,
- String message)
- {
- this.chatId = chatId;
- this.when = when;
- this.sender = sender;
- this.message = message;
- }
-
- public String getChatId()
- {
- return this.chatId;
- }
-
- public long getWhen()
- {
- return this.when;
- }
-
- public String getSender()
- {
- return this.sender;
- }
-
- public String getMessage()
- {
- return this.message;
- }
-
-}
-
+/**
+ *
+ */
+package net.sf.colossus.webcommon;
+
+
+public class ChatMessage
+{
+ String chatId;
+ long when;
+ String sender;
+ String message;
+
+ public ChatMessage(String chatId, long when, String sender,
+ String message)
+ {
+ this.chatId = chatId;
+ this.when = when;
+ this.sender = sender;
+ this.message = message;
+ }
+
+ public String getChatId()
+ {
+ return this.chatId;
+ }
+
+ public long getWhen()
+ {
+ return this.when;
+ }
+
+ public String getSender()
+ {
+ return this.sender;
+ }
+
+ public String getMessage()
+ {
+ return this.message;
+ }
+
+}
+
Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/ChatMessage.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/FormatWhen.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/FormatWhen.java 2015-04-09 16:14:41 UTC (rev 5374)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/FormatWhen.java 2015-04-09 16:48:13 UTC (rev 5375)
@@ -1,63 +1,63 @@
-/**
- *
- */
-package net.sf.colossus.webcommon;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class FormatWhen
-{
- public static final String DATE_FORMAT = "yyyy-MM-dd";
- public static final String TIME_FORMAT = "HH:mm:ss";
-
- private final SimpleDateFormat dateFormatter;
- private final SimpleDateFormat timeFormatter;
-
- private String datePrev;
- private String changedDateString = null;
-
- public FormatWhen()
- {
- datePrev = "";
- dateFormatter = new SimpleDateFormat(DATE_FORMAT);
- timeFormatter = new SimpleDateFormat(TIME_FORMAT);
-
- }
-
- /* call this *after* timeAsString() call
- * It will return the new date, if changed, null otherwise */
-
- public String hasDateChanged()
- {
- return changedDateString;
- }
-
- public String timeAsString(long when)
- {
- Date whenDate = new Date(when);
- String timeNow = timeFormatter.format(whenDate);
- String dateNow = dateFormatter.format(whenDate);
-
- if (!dateNow.equals(datePrev))
- {
- changedDateString = dateNow;
- }
- else
- {
- changedDateString = null;
- }
- datePrev = dateNow;
-
- return timeNow;
- }
-
- public String timeAndDateAsString(long when)
- {
- Date whenDate = new Date(when);
- String timeNow = timeFormatter.format(whenDate);
- String dateNow = dateFormatter.format(whenDate);
-
- return dateNow + " " + timeNow;
- }
+/**
+ *
+ */
+package net.sf.colossus.webcommon;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class FormatWhen
+{
+ public static final String DATE_FORMAT = "yyyy-MM-dd";
+ public static final String TIME_FORMAT = "HH:mm:ss";
+
+ private final SimpleDateFormat dateFormatter;
+ private final SimpleDateFormat timeFormatter;
+
+ private String datePrev;
+ private String changedDateString = null;
+
+ public FormatWhen()
+ {
+ datePrev = "";
+ dateFormatter = new SimpleDateFormat(DATE_FORMAT);
+ timeFormatter = new SimpleDateFormat(TIME_FORMAT);
+
+ }
+
+ /* call this *after* timeAsString() call
+ * It will return the new date, if changed, null otherwise */
+
+ public String hasDateChanged()
+ {
+ return changedDateString;
+ }
+
+ public String timeAsString(long when)
+ {
+ Date whenDate = new Date(when);
+ String timeNow = timeFormatter.format(whenDate);
+ String dateNow = dateFormatter.format(whenDate);
+
+ if (!dateNow.equals(datePrev))
+ {
+ changedDateString = dateNow;
+ }
+ else
+ {
+ changedDateString = null;
+ }
+ datePrev = dateNow;
+
+ return timeNow;
+ }
+
+ public String timeAndDateAsString(long when)
+ {
+ Date whenDate = new Date(when);
+ String timeNow = timeFormatter.format(whenDate);
+ String dateNow = dateFormatter.format(whenDate);
+
+ return dateNow + " " + timeNow;
+ }
}
\ No newline at end of file
Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/FormatWhen.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java 2015-04-09 16:14:41 UTC (rev 5374)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java 2015-04-09 16:48:13 UTC (rev 5375)
@@ -1,21 +1,21 @@
-package net.sf.colossus.webcommon;
-
-
-import java.rmi.AccessException;
-import java.rmi.NotBoundException;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-
-public interface IGameManager extends Remote
-{
- public void tellEvent(String description) throws RemoteException;
-
- public void registerGame(String gameId) throws RemoteException,
- NotBoundException;
-
- public void unregisterGame(String gameId) throws AccessException,
- NotBoundException, RemoteException;
-}
-
-
+package net.sf.colossus.webcommon;
+
+
+import java.rmi.AccessException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+
+public interface IGameManager extends Remote
+{
+ public void tellEvent(String description) throws RemoteException;
+
+ public void registerGame(String gameId) throws RemoteException,
+ NotBoundException;
+
+ public void unregisterGame(String gameId) throws AccessException,
+ NotBoundException, RemoteException;
+}
+
+
Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IManagedGame.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IManagedGame.java 2015-04-09 16:14:41 UTC (rev 5374)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IManagedGame.java 2015-04-09 16:48:13 UTC (rev 5375)
@@ -1,11 +1,11 @@
-package net.sf.colossus.webcommon;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-public interface IManagedGame extends Remote
-{
- public String tellStatus() throws RemoteException;
-
-
-}
+package net.sf.colossus.webcommon;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface IManagedGame extends Remote
+{
+ public String tellStatus() throws RemoteException;
+
+
+}
Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IManagedGame.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IPortProvider.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IPortProvider.java 2015-04-09 16:14:41 UTC (rev 5374)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IPortProvider.java 2015-04-09 16:48:13 UTC (rev 5375)
@@ -1,13 +1,13 @@
-/**
- *
- */
-package net.sf.colossus.webcommon;
-
-
-/**
- *
- */
-public interface IPortProvider
-{
- public abstract int getFreePort(GameInfo gi);
-}
+/**
+ *
+ */
+package net.sf.colossus.webcommon;
+
+
+/**
+ *
+ */
+public interface IPortProvider
+{
+ public abstract int getFreePort(GameInfo gi);
+}
Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/IPortProvider.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/UserDB.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/UserDB.java 2015-04-09 16:14:41 UTC (rev 5374)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/UserDB.java 2015-04-09 16:48:13 UTC (rev 5375)
@@ -1,416 +1,416 @@
-package net.sf.colossus.webcommon;
-
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import net.sf.colossus.webserver.WebServerClient;
-
-
-public class UserDB
-{
- private static final Logger LOGGER = Logger.getLogger(UserDB.class
- .getName());
-
- private final int maxUsers;
-
- private final String usersFile;
-
- private final HashMap<String, User> userMap = new HashMap<String, User>();
- private final HashMap<String, User> loggedInUserMap = new HashMap<String, User>();
-
- private final HashMap<String, User> pendingRegistrations = new HashMap<String, User>();
-
- private long highestExistingId;
-
- public UserDB(String filename, int maxUsersVal)
- {
- maxUsers = maxUsersVal;
- usersFile = filename;
- if (usersFile != null)
- {
- readUsersFromFile();
- }
- }
-
- public int getUserCount()
- {
- synchronized (userMap)
- {
- return userMap.size();
- }
- }
-
- public void updateLoggedinStatus(User u, WebServerClient wsc)
- {
- String username = u.getName();
- synchronized (loggedInUserMap)
- {
- if (wsc == null)
- {
- if (loggedInUserMap.containsKey(username))
- {
- loggedInUserMap.remove(username);
- }
- }
- else
- {
- loggedInUserMap.put(username, u);
- }
- }
-
- }
- public boolean isUserOnline(User u)
- {
- synchronized (loggedInUserMap)
- {
- return loggedInUserMap.containsKey(u.getName());
- }
- }
-
- public Collection<User> getLoggedInUsers()
- {
- synchronized (loggedInUserMap)
- {
- Collection<User> c = new LinkedList<User>();
- c.addAll(loggedInUserMap.values());
- return c;
- }
- }
-
- public User findUserByName(String name)
- {
- synchronized (userMap)
- {
- String nameAllLower = name.toLowerCase();
- return userMap.get(nameAllLower);
- }
- }
-
- public String getLoggedInNamesAsString(String useSeparator)
- {
- String names = "<none>";
- String separator = "";
-
- synchronized (loggedInUserMap)
- {
- if (!loggedInUserMap.isEmpty())
- {
- StringBuilder list = new StringBuilder("");
- for (String key : loggedInUserMap.keySet())
- {
- list.append(separator);
- list.append(key);
- separator = useSeparator;
- }
- names = list.toString();
- }
- }
- return names;
- }
-
- // still dummy
- public int getDeadCount()
- {
- return 0;
- }
-
- // still dummy
- public int getEnrolledCount()
- {
- return 0;
- }
-
- // still dummy
- public int getPlayingCount()
- {
- return 0;
- }
-
- public int getLoggedInCount()
- {
- synchronized (loggedInUserMap)
- {
- return loggedInUserMap.size();
- }
- }
-
- public Collection<User> getAllUsers()
- {
- synchronized (userMap)
- {
- Collection<User> c = new LinkedList<User>();
- c.addAll(userMap.values());
- return c;
- }
- }
-
- /**
- * Given a username and password, verifies that the user
- * is allowed to login with that password.
- * @param username
- * @param password
- * @return reasonLoginFailed (String), null if login ok
- **/
- public String verifyLogin(String username, String password)
- {
- String reasonLoginFailed = null;
-
- User user = findUserByName(username);
-
- if (user == null)
- {
- reasonLoginFailed = "Invalid username";
- }
- else if (password != null && user.isCorrectPassword(password))
- {
- // ok, return null to indicate all is fine
- }
- else
- {
- reasonLoginFailed = "Invalid username/password";
- }
-
- return reasonLoginFailed;
- }
-
- public String registerUser(String username, String password, String email,
- IColossusMail mailObject)
- {
- boolean isAdmin = false;
-
- String usernameAllLc = username;
- usernameAllLc = usernameAllLc.toLowerCase();
- if (usernameAllLc.startsWith("guest")
- || usernameAllLc.startsWith("anonym"))
- {
- String problem = "Usernames starting with 'guest' or 'anonym' "
- + " are reserved for special purposes!";
- return problem;
- }
- User alreadyExisting = findUserByName(username);
- if (alreadyExisting != null)
- {
- String problem = "User " + username + " does already exist.";
- return problem;
- }
- else if (getUserCount() >= maxUsers)
- {
- String problem = "Maximum number of accounts )" + maxUsers
- + ") reached - no more registrations possible,"
- + " until some administrator checks the situation.";
- return problem;
- }
- else
- {
- highestExistingId++;
- User u = new User(highestExistingId, username, password, email,
- isAdmin, null, null, null, 0);
- String cCode = u.getLastConfirmationCode();
- User.LOGGER.fine("Confirmation code for user " + username
- + " is: " + cCode);
-
- String reason = sendConfirmationMail(username, email, cCode,
- mailObject);
- if (reason != null)
- {
- // mail sending failed, for some reason. Let user know it.
- return reason;
- }
-
- pendingRegistrations.put(username, u);
- // so far everything fine. Now client shall request the conf. code
-
- reason = User.PROVIDE_CONFCODE;
- return reason;
- }
- }
-
-
- public String sendConfirmationMail(String username, String email,
- String confCode, IColossusMail mailObject)
- {
- // this is in webcommon package:
- return mailObject.sendConfirmationMail(username, email, confCode);
- }
-
- public String confirmRegistration(String username, String confirmationCode)
- {
- String reason = "";
- if (confirmationCode == null || confirmationCode.equals("null")
- || confirmationCode.equals(""))
- {
- reason = "Missing confirmation code";
- return reason;
- }
-
- String msg = "User " + username + " attempts confirmation "
- + "with code '" + confirmationCode + "'.";
- User.LOGGER.fine(msg);
-
- reason = confirmIfCorrectCode(username, confirmationCode);
- return reason;
- }
-
- private String confirmIfCorrectCode(String username,
- String tryConfirmationCode)
- {
- User u = pendingRegistrations.get(username);
- if (u == null)
- {
- return "No confirmation pending for this username";
- }
-
- if (!u.getLastConfirmationCode().equals(tryConfirmationCode))
- {
- return User.WRONG_CONFCODE;
- }
-
- User.LOGGER.info("Registration confirmed for user '" + username
- + "', email '" + u.getEmail() + "'.");
-
- pendingRegistrations.remove(username);
- storeUser(u);
- storeUsersToFile();
-
- return null;
- }
-
- public String changeProperties(String username, String oldPW,
- String newPW, String email, Boolean isAdmin)
- {
- String reason;
-
- User u = findUserByName(username);
- if (u == null)
- {
- reason = "User does not exist";
- return reason;
- }
- else if ((reason = verifyLogin(username, oldPW)) != null)
- {
- return reason;
- }
- else
- {
- u.setProperties(newPW, email, isAdmin);
- storeUsersToFile();
- return null;
- }
- }
-
- private void readUsersFromFile()
- {
- long maxId = 0;
- try
- {
- BufferedReader users = new BufferedReader(new InputStreamReader(
- new FileInputStream(usersFile)));
-
- String line = null;
- while ((line = users.readLine()) != null)
- {
- if (line.startsWith("#"))
- {
- // ignore comment line
- }
- else if (line.matches("\\s*"))
- {
- // ignore empty line
- }
- else
- {
- User u = User.makeUserFromUserLine(line);
- if (u != null)
- {
- storeUser(u);
- if (u.getId() > maxId)
- {
- maxId = u.getId();
- }
- }
- }
- }
- this.highestExistingId = maxId;
- users.close();
- }
- catch (FileNotFoundException e)
- {
- LOGGER.log(Level.SEVERE,
- "Users file " + usersFile + " not found!", e);
- System.exit(1);
- }
- catch (IOException e)
- {
- LOGGER.log(Level.SEVERE, "IOException while reading users file "
- + usersFile + "!", e);
- System.exit(1);
- }
- }
+package net.sf.colossus.webcommon;
- public void storeUsersToFile()
- {
- if (usersFile == null)
- {
- User.LOGGER.log(Level.SEVERE, "UsersFile name is null!");
- System.exit(1);
- }
-
- // LOGGER.log(Level.FINE, "Storing users back to file " + filename);
-
- PrintWriter out = null;
- try
- {
- out = new PrintWriter(new FileOutputStream(usersFile));
-
- Collection<User> users = new LinkedList<User>();
- users.addAll(getAllUsers());
-
- for (User user : users)
- {
- String line = user.makeLine();
- out.println(line);
- }
- out.close();
- }
- catch (FileNotFoundException e)
- {
- User.LOGGER.log(Level.SEVERE, "Writing users file " + usersFile
- + "failed: FileNotFoundException: ", e);
- System.exit(1);
- }
- }
-
- private void storeUser(User u)
- {
- String name = u.getName();
- String nameAllLower = name.toLowerCase();
- synchronized (userMap)
- {
- userMap.put(nameAllLower, u);
- }
- }
-
- public void cleanup()
- {
- synchronized (userMap)
- {
- userMap.clear();
- }
- synchronized (loggedInUserMap)
- {
- loggedInUserMap.clear();
- }
- }
-
-}
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import net.sf.colossus.webserver.WebServerClient;
+
+
+public class UserDB
+{
+ private static final Logger LOGGER = Logger.getLogger(UserDB.class
+ .getName());
+
+ private final int maxUsers;
+
+ private final String usersFile;
+
+ private final HashMap<String, User> userMap = new HashMap<String, User>();
+ private final HashMap<String, User> loggedInUserMap = new HashMap<String, User>();
+
+ private final HashMap<String, User> pendingRegistrations = new HashMap<String, User>();
+
+ private long highestExistingId;
+
+ public UserDB(String filename, int maxUsersVal)
+ {
+ maxUsers = maxUsersVal;
+ usersFile = filename;
+ if (usersFile != null)
+ {
+ readUsersFromFile();
+ }
+ }
+
+ public int getUserCount()
+ {
+ synchronized (userMap)
+ {
+ return userMap.size();
+ }
+ }
+
+ public void updateLoggedinStatus(User u, WebServerClient wsc)
+ {
+ String username = u.getName();
+ synchronized (loggedInUserMap)
+ {
+ if (wsc == null)
+ {
+ if (loggedInUserMap.containsKey(username))
+ {
+ loggedInUserMap.remove(username);
+ }
+ }
+ else
+ {
+ loggedInUserMap.put(username, u);
+ }
+ }
+
+ }
+ public boolean isUserOnline(User u)
+ {
+ synchronized (loggedInUserMap)
+ {
+ return loggedInUserMap.containsKey(u.getName());
+ }
+ }
+
+ public Collection<User> getLoggedInUsers()
+ {
+ synchronized (loggedInUserMap)
+ {
+ Collection<User> c = new LinkedList<User>();
+ c.addAll(loggedInUserMap.values());
+ return c;
+ }
+ }
+
+ public User findUserByName(String name)
+ {
+ synchronized (userMap)
+ {
+ String nameAllLower = name.toLowerCase();
+ return userMap.get(nameAllLower);
+ }
+ }
+
+ public String getLoggedInNamesAsString(String useSeparator)
+ {
+ String names = "<none>";
+ String separator = "";
+
+ synchronized (loggedInUserMap)
+ {
+ if (!loggedInUserMap.isEmpty())
+ {
+ StringBuilder list = new StringBuilder("");
+ for (String key : loggedInUserMap.keySet())
+ {
+ list.append(separator);
+ list.append(key);
+ separator = useSeparator;
+ }
+ names = list.toString();
+ }
+ }
+ return names;
+ }
+
+ // still dummy
+ public int getDeadCount()
+ {
+ return 0;
+ }
+
+ // still dummy
+ public int getEnrolledCount()
+ {
+ return 0;
+ }
+
+ // still dummy
+ public int getPlayingCount()
+ {
+ return 0;
+ }
+
+ public int getLoggedInCount()
+ {
+ synchronized (loggedInUserMap)
+ {
+ return loggedInUserMap.size();
+ }
+ }
+
+ public Collection<User> getAllUsers()
+ {
+ synchronized (userMap)
+ {
+ Collection<User> c = new LinkedList<User>();
+ c.addAll(userMap.values());
+ return c;
+ }
+ }
+
+ /**
+ * Given a username and password, verifies that the user
+ * is allowed to login with that password.
+ * @param username
+ * @param password
+ * @return reasonLoginFailed (String), null if login ok
+ **/
+ public String verifyLogin(String username, String password)
+ {
+ String reasonLoginFailed = null;
+
+ User user = findUserByName(username);
+
+ if (user == null)
+ {
+ reasonLoginFailed = "Invalid username";
+ }
+ else if (password != null && user.isCorrectPassword(password))
+ {
+ // ok, return null to indicate all is fine
+ }
+ else
+ {
+ reasonLoginFailed = "Invalid username/password";
+ }
+
+ return reasonLoginFailed;
+ }
+
+ public String registerUser(String username, String password, String email,
+ IColossusMail mailObject)
+ {
+ boolean isAdmin = false;
+
+ String usernameAllLc = username;
+ usernameAllLc = usernameAllLc.toLowerCase();
+ if (usernameAllLc.startsWith("guest")
+ || usernameAllLc.startsWith("anonym"))
+ {
+ String problem = "Usernames starting with 'guest' or 'anonym' "
+ + " are reserved for special purposes!";
+ return problem;
+ }
+ User alreadyExisting = findUserByName(username);
+ if (alreadyExisting != null)
+ {
+ String problem = "User " + username + " does already exist.";
+ return problem;
+ }
+ else if (getUserCount() >= maxUsers)
+ {
+ String problem = "Maximum number of accounts )" + maxUsers
+ + ") reached - no more registrations possible,"
+ + " until some administrator checks the situation.";
+ return problem;
+ }
+ else
+ {
+ highestExistingId++;
+ User u = new User(highestExistingId, username, password, email,
+ isAdmin, null, null, null, 0);
+ String cCode = u.getLastConfirmationCode();
+ User.LOGGER.fine("Confirmation code for user " + username
+ + " is: " + cCode);
+
+ String reason = sendConfirmationMail(username, email, cCode,
+ mailObject);
+ if (reason != null)
+ {
+ // mail sending failed, for some reason. Let user know it.
+ return reason;
+ }
+
+ pendingRegistrations.put(username, u);
+ // so far everything fine. Now client shall request the conf. code
+
+ reason = User.PROVIDE_CONFCODE;
+ return reason;
+ }
+ }
+
+
+ public String sendConfirmationMail(String username, String email,
+ String confCode, IColossusMail mailObject)
+ {
+ // this is in webcommon package:
+ return mailObject.sendConfirmationMail(username, email, confCode);
+ }
+
+ public String confirmRegistration(String username, String confirmationCode)
+ {
+ String reason = "";
+ if (confirmationCode == null || confirmationCode.equals("null")
+ || confirmationCode.equals(""))
+ {
+ reason = "Missing confirmation code";
+ return reason;
+ }
+
+ String msg = "User " + username + " attempts confirmation "
+ + "with code '" + confirmationCode + "'.";
+ User.LOGGER.fine(msg);
+
+ reason = confirmIfCorrectCode(username, confirmationCode);
+ return reason;
+ }
+
+ private String confirmIfCorrectCode(String username,
+ String tryConfirmationCode)
+ {
+ User u = pendingRegistrations.get(username);
+ if (u == null)
+ {
+ return "No confirmation pending for this username";
+ }
+
+ if (!u.getLastConfirmationCode().equals(tryConfirmationCode))
+ {
+ return User.WRONG_CONFCODE;
+ }
+
+ User.LOGGER.info("Registration confirmed for user '" + username
+ + "', email '" + u.getEmail() + "'.");
+
+ pendingRegistrations.remove(username);
+ storeUser(u);
+ storeUsersToFile();
+
+ return null;
+ }
+
+ public String changeProperties(String username, String oldPW,
+ String newPW, String email, Boolean isAdmin)
+ {
+ String reason;
+
+ User u = findUserByName(username);
+ if (u == null)
+ {
+ reason = "User does not exist";
+ return reason;
+ }
+ else if ((reason = verifyLogin(username, oldPW)) != null)
+ {
+ return reason;
+ }
+ else
+ {
+ u.setProperties(newPW, email, isAdmin);
+ storeUsersToFile();
+ return null;
+ }
+ }
+
+ private void readUsersFromFile()
+ {
+ long maxId = 0;
+ try
+ {
+ BufferedReader users = new BufferedReader(new InputStreamReader(
+ new FileInputStream(usersFile)));
+
+ String line = null;
+ while ((line = users.readLine()) != null)
+ {
+ if (line.startsWith("#"))
+ {
+ // ignore comment line
+ }
+ else if (line.matches("\\s*"))
+ {
+ // ignore empty line
+ }
+ else
+ {
+ User u = User.makeUserFromUserLine(line);
+ if (u != null)
+ {
+ storeUser(u);
+ if (u.getId() > maxId)
+ {
+ maxId = u.getId();
+ }
+ }
+ }
+ }
+ this.highestExistingId = maxId;
+ users.close();
+ }
+ catch (FileNotFoundException e)
+ {
+ LOGGER.log(Level.SEVERE,
+ "Users file " + usersFile + " not found!", e);
+ System.exit(1);
+ }
+ catch (IOException e)
+ {
+ LOGGER.log(Level.SEVERE, "IOException while reading users file "
+ + usersFile + "!", e);
+ System.exit(1);
+ }
+ }
+
+ public void storeUsersToFile()
+ {
+ if (usersFile == null)
+ {
+ User.LOGGER.log(Level.SEVERE, "UsersFile name is null!");
+ System.exit(1);
+ }
+
+ // LOGGER.log(Level.FINE, "Storing users back to file " + filename);
+
+ PrintWriter out = null;
+ try
+ {
+ out = new PrintWriter(new FileOutputStream(usersFile));
+
+ Collection<User> users = new LinkedList<User>();
+ users.addAll(getAllUsers());
+
+ for (User user : users)
+ {
+ String line = user.makeLine();
+ out.println(line);
+ }
+ out.close();
+ }
+ catch (FileNotFoundException e)
+ {
+ User.LOGGER.log(Level.SEVERE, "Writing users file " + usersFile
+ + "failed: FileNotFoundException: ", e);
+ System.exit(1);
+ }
+ }
+
+ private void storeUser(User u)
+ {
+ String name = u.getName();
+ String nameAllLower = name.toLowerCase();
+ synchronized (userMap)
+ {
+ userMap.put(nameAllLower, u);
+ }
+ }
+
+ public void cleanup()
+ {
+ synchronized (userMap)
+ {
+ userMap.clear();
+ }
+ synchronized (loggedInUserMap)
+ {
+ loggedInUserMap.clear();
+ }
+ }
+
+}
Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/webcommon/UserDB.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ChatChannel.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ChatChannel.java 2015-04-09 16:14:41 UTC (rev 5374)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ChatChannel.java 2015-04-09 16:48:13 UTC (rev 5375)
@@ -1,321 +1,321 @@
-package net.sf.colossus.webserver;
-
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import net.sf.colossus.webcommon.ChatMessage;
-import net.sf.colossus.webcommon.FormatWhen;
-import net.sf.colossus.webcommon.IWebClient;
-import net.sf.colossus.webcommon.User;
-import net.sf.colossus.webcommon.UserDB;
-
-
-public class ChatChannel
-{
- private static final Logger LOGGER = Logger.getLogger(ChatChannel.class
- .getName());
-
- private final UserDB userDB;
- private final String chatId;
- private final ChatMsgStorage storage;
- private final PrintWriter chatLog;
- private final FormatWhen whenFormatter;
-
- private final static String doubledashes = "=========================";
-
- private final static String[] chatHelp = new String[] { "Chat help:", "",
- "/help, /h, /? (show help)", "/ping (notify a certain user)",
- "/contact (how to contact admin)",
- "/userinfo (shows what info server has about you)", "",
- "Use /help <keyword> for detailed help. E.g. /help ping how to use ping." };
-
- private final static String[] pingHelp = new String[] {
- "Using /ping:",
- "",
- "To notify another user (it will give some beeps, and display your given message"
- + "in a popup dialog),",
- "you can use the /ping command:",
- " /ping UserName Here comes the message",
- "If the user's name contains spaces, it must be within double quotes:",
- " /ping \"Lengthy User Name\" Here comes the message" };
-
- private final static String[] contactHelp = new String[] {
- "Using /contact:",
- "",
- "To contact the administrator of this server, send a mail to su...@pl... .",
- "We also encourage you to use the \"General\" forum, the bugs tracker or the feature",
- "request tracker on our project page on Sourceforge:",
- " http://sourceforge.net/projects/colossus/" };
-
- public ChatChannel(String id, WebServerOptions options, UserDB userDB)
- {
- this.userDB = userDB;
- this.chatId = id;
- this.storage = new ChatMsgStorage(this, options);
- this.chatLog = openLogForAppend(options);
- this.whenFormatter = new FormatWhen();
- }
-
- public String getChannelId()
- {
- return chatId;
- }
-
- public void dispose()
- {
- storage.dispose();
- }
-
- public void createWelcomeMessage()
- {
- long now = new Date().getTime();
- ChatMessage startMsg = new ChatMessage(this.chatId, now, "SYSTEM",
- "WebServer started. Welcome!!");
- synchronized(storage)
- {
- storage.storeMessage(startMsg);
- }
- }
-
- /** Send message of the day lines to one client. */
- public void deliverMessageOfTheDayToClient(String chatId,
- IWebClient client, List<String> lines)
- {
- sendLinesToClient(chatId, client, lines, false, "SYSTEM");
- }
-
- public void handleUnknownCommand(String msgAllLower, String chatId,
- IWebClient client)
- {
- String[] lines = new String[] {
- "Sorry, '" + msgAllLower + "' is not a recognized command.",
- "Use /help to get a list of valid commands." };
- sendLinesToClient(chatId, client, Arrays.asList(lines), true, "");
- }
-
- public void sendHelpToClient(String msgAllLower, String chatId,
- IWebClient client)
- {
- List<String> words = Arrays.asList(msgAllLower.split(" +"));
- if (words.size() == 1)
- {
- sendLinesToClient(chatId, client, Arrays.asList(chatHelp), true,
- "");
- }
- else
- {
- if (words.get(1).startsWith("/ping")
- || words.get(1).startsWith("ping"))
- {
- sendLinesToClient(chatId, client, Arrays.asList(pingHelp),
- true, "");
- }
- else if (words.get(1).startsWith("/contact")
- || words.get(1).startsWith("contact"))
- {
- showContactHelp(chatId, client);
- }
- else
- {
- String[] noSuchHelp = new String[] { "Sorry, no specific help available about '"
- + words.get(1) + "'." };
- sendLinesToClient(chatId, client, Arrays.asList(noSuchHelp),
- true, "");
- }
- }
- }
-
- /**
- * @param chatId Id of the chat
- * @param client WebClient connection who requested the contact help
- */
- public void showContactHelp(String chatId, IWebClient client)
- {
- sendLinesToClient(chatId, client, Arrays.asList(contactHelp),
- true, "");
- }
-
- /** Send an arraylist full of lines to one client. */
- public void sendLinesToClient(String chatId, IWebClient client,
- List<String> lines, boolean spacer, String sender)
- {
- long when = new Date().getTime();
- boolean isResent = false;
-
- if (spacer)
- {
- client.chatDeliver(chatId, when, sender, "", isResent);
- }
- for (String line : lines)
- {
- client.chatDeliver(chatId, when, sender, line, isResent);
- }
- if (spacer)
- {
- client.chatDeliver(chatId, when, sender, "", isResent);
- }
-
- }
-
- // handleShowInfo(sender, message, this);
- public void handleShowInfo(IWebClient client, User user)
- {
- List<String> lines = new ArrayList<String>();
- lines.add("Server has following information about you:");
- lines.add(" Name: " + user.getName());
- lines.add(" Email: " + user.getEmail());
- lines.add(" Registered: " + user.getCreated()
- + " [SERVER TIME, i.e. Central European time]");
- long secs = user.getOnlineTime();
- lines.add(" Online time: " + secs + " seconds ("
- + onlineTimeFromSeconds(secs) + ")");
- sendLinesToClient(chatId, client, lines, true, "SYSTEM");
- }
-
- @SuppressWarnings("boxing")
- private String onlineTimeFromSeconds(long totalsecs)
- {
- long total = totalsecs;
- long secs = total % 60;
- total -= secs;
- total /= 60;
- long mins = total % 60;
- total -= mins;
- total /= 60;
- long hours = total % 24;
- total -= hours;
- total /= 24;
- long days = total;
-
- String
- "%d days, %d hours, %d minutes, %d seconds", days, hours, mins,
- secs);
- return onlineTime;
- }
-
- // TODO is this perhaps obsolete nowadays?
- /** Send message of the day lines to one client. */
- public void deliverOldVersionWarning(String chatId, String userName,
- IWebClient client)
- {
- long when = new Date().getTime();
- String sender = "SYSTEM";
- boolean isResent = false;
-
- ArrayList<String> lines = new ArrayList<String>();
- lines.add("");
- lines
- .add("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
- lines.add("");
- lines.add(" Hello " + userName + ", please note:");
- lines
- .add(" You are using a Colossus version older than 0.10.3. See message above!");
- lines.add("");
- lines
- .add("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
- lines.add("");
-
- for (String line : lines)
- {
- client.chatDeliver(chatId, when, sender, line, isResent);
- }
- }
-
- public void createStoreAndDeliverMessage(String sender, String message)
- {
- long now = new Date().getTime();
- ChatMessage msg = new ChatMessage(this.chatId,
- now, sender, message);
- synchronized (storage)
- {
- storage.storeMessage(msg);
- }
- appendToChatlog(msg);
- deliverMessage(msg, userDB);
- }
-
- private void deliverMessage(ChatMessage msg, UserDB userDB)
- {
- Collection<User> users = userDB.getLoggedInUsers();
- for (User u : users)
- {
- IWebClient client = u.getWebserverClient();
- deliverMessageToClient(msg, client, false);
- }
- }
-
- private void deliverMessageToClient(ChatMessage msg, IWebClient client,
- boolean isResent)
- {
- client.chatDeliver(msg.getChatId(), msg.getWhen(), msg.getSender(),
- msg.getMessage(), isResent);
- }
-
- public void tellLastMessagesToOne(IWebClient client)
- {
- synchronized (storage)
- {
- for (ChatMessage msg : storage.getLastNChatMessages())
- {
- deliverMessageToClient(msg, client, true);
- }
- }
- long now = new Date().getTime();
- client.chatDeliver(chatId, now, null, null, true);
- }
-
- private PrintWriter openLogForAppend(WebServerOptions options)
- {
- String usersFileDirectory = options
- .getStringOption(WebServerConstants.optDataDirectory);
- if (usersFileDirectory == null)
- {
- LOGGER
- .severe("Data Directory (for chat messages log file) is null! Define it in cf file!");
- System.exit(1);
- }
- String filename = "ChatLog-" + getChannelId() + ".txt";
-
- PrintWriter chatLog = null;
- try
- {
- boolean append = true;
- chatLog = new PrintWriter(new FileOutputStream(new File(
- usersFileDirectory, filename), append));
- }
- catch (FileNotFoundException e)
- {
- LOGGER.log(Level.SEVERE, "Writing char messages file " + filename
- + "failed: FileNotFoundException: ", e);
- }
- return chatLog;
- }
-
- private void appendToChatlog(ChatMessage msg)
- {
- String sender = msg.getSender();
- String message = msg.getMessage();
- long when = msg.getWhen();
-
-
- String whenTime = whenFormatter.timeAsString(when);
- String dateChange = whenFormatter.hasDateChanged();
- if (dateChange != null)
- {
- chatLog.println(doubledashes + " " + dateChange + " "
- + doubledashes);
- }
- chatLog.println(whenTime + " " + sender + ": " + message);
- chatLog.flush();
- }
-}
+package net.sf.colossus.webserver;
+
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import net.sf.colossus.webcommon.ChatMessage;
+import net.sf.colossus.webcommon.FormatWhen;
+import net.sf.colossus.webcommon.IWebClient;
+import net.sf.colossus.webcommon.User;
+import net.sf.colossus.webcommon.UserDB;
+
+
+public class ChatChannel
+{
+ private static final Logger LOGGER = Logger.getLogger(ChatChannel.class
+ .getName());
+
+ private final UserDB userDB;
+ private final String chatId;
+ private final ChatMsgStorage storage;
+ private final PrintWriter chatLog;
+ private final FormatWhen whenFormatter;
+
+ private final static String doubledashes = "=========================";
+
+ private final static String[] chatHelp = new String[] { "Chat help:", "",
+ "/help, /h, /? (show help)", "/ping (notify a certain user)",
+ "/contact (how to contact admin)",
+ "/userinfo (shows what info server has about you)", "",
+ "Use /help <keyword> for detailed help. E.g. /help ping how to use ping." };
+
+ private final static String[] pingHelp = new String[] {
+ "Using /ping:",
+ "",
+ "To notify another user (it will give some beeps, and display your given message"
+ + "in a popup dialog),",
+ "you can use the /ping command:",
+ " /ping UserName Here comes the message",
+ "If the user's name contains spaces, it must be within double quotes:",
+ " /ping \"Lengthy User Name\" Here comes the message" };
+
+ private final static String[] contactHelp = new String[] {
+ "Using /contact:",
+ "",
+ "To contact the administrator of this server, send a mail to su...@pl... .",
+ "We also encourage you to use the \"General\" forum, the bugs tracker or the feature",
+ "request tracker on our project page on Sourceforge:",
+ " http://sourceforge.net/projects/colossus/" };
+
+ public ChatChannel(String id, WebServerOptions options, UserDB userDB)
+ {
+ this.userDB = userDB;
+ this.chatId = id;
+ this.storage = new ChatMsgStorage(this, options);
+ this.chatLog = openLogForAppend(options);
+ this.whenFormatter = new FormatWhen();
+ }
+
+ public String getChannelId()
+ {
+ return chatId;
+ }
+
+ public void dispose()
+ {
+ storage.dispose();
+ }
+
+ public void createWelcomeMessage()
+ {
+ long now = new Date().getTime();
+ ChatMessage startMsg = new ChatMessage(this.chatId, now, "SYSTEM",
+ "WebServer started. Welcome!!");
+ synchronized(storage)
+ {
+ storage.storeMessage(startMsg);
+ }
+ }
+
+ /** Send message of the day lines to one client. */
+ public void deliverMessageOfTheDayToClient(String chatId,
+ IWebClient client, List<String> lines)
+ {
+ sendLinesToClient(chatId, client, lines, false, "SYSTEM");
+ }
+
+ public void handleUnknownCommand(String msgAllLower, String chatId,
+ IWebClient client)
+ {
+ String[] lines = new String[] {
+ "Sorry, '" + msgAllLower + "' is not a recognized command.",
+ "Use /help to get a list of valid commands." };
+ sendLinesToClient(chatId, client, Arrays.asList(lines), true, "");
+ }
+
+ public void sendHelpToClient(String msgAllLower, String chatId,
+ IWebClient client)
+ {
+ List<String> words = Arrays.asList(msgAllLower.split(" +"));
+ if (words.size() == 1)
+ {
+ sendLinesToClient(chatId, client, Arrays.asList(chatHelp), true,
+ "");
+ }
+ else
+ {
+ if (words.get(1).startsWith("/ping")
+ || words.get(1).startsWith("ping"))
+ {
+ sendLinesToClient(chatId, client, Arrays.asList(pingHelp),
+ true, "");
+ }
+ else if (words.get(1).startsWith("/contact")
+ || words.get(1).startsWith("contact"))
+ {
+ showContactHelp(chatId, client);
+ }
+ else
+ {
+ String[] noSuchHelp = new String[] { "Sorry, no specific help available about '"
+ + words.get(1) + "'." };
+ sendLinesToClient(chatId, client, Arrays.asList(noSuchHelp),
+ true, "");
+ }
+ }
+ }
+
+ /**
+ * @param chatId Id of the chat
+ * @param client WebClient connection who requested the contact help
+ */
+ public void showContactHelp(String chatId, IWebClient client)
+ {
+ sendLinesToClient(chatId, client, Arrays.asList(contactHelp),
+ true, "");
+ }
+
+ /** Send an arraylist full of lines to one client. */
+ public void sendLinesToClient(String chatId, IWebClient client,
+ List<String> lines, boolean spacer, String sender)
+ {
+ long when = new Date().getTime();
+ boolean isResent = false;
+
+ if (spacer)
+ {
+ client.chatDeliver(chatId, when, sender, "", isResent);
+ }
+ for (String line : lines)
+ {
+ client.chatDeliver(chatId, when, sender, line, isResent);
+ }
+ if (spacer)
+ {
+ client.chatDeliver(chatId, when, sender, "", isResent);
+ }
+
+ }
+
+ // handleShowInfo(sender, message, this);
+ public void handleShowInfo(IWebClient client, User user)
+ {
+ List<String> lines = new ArrayList<String>();
+ lines.add("Server has following information about you:");
+ lines.add(" Name: " + user.getName());
+ lines.add(" Email: " + user.getEmail());
+ lines.add(" Registered: " + user.getCreated()
+ + " [SERVER TIME, i.e. Central European time]");
+ long secs = user.getOnlineTime();
+ lines.add(" Online time: " + secs + " seconds ("
+ + onlineTimeFromSeconds(secs) + ")");
+ sendLinesToClient(chatId, client, lines, true, "SYSTEM");
+ }
+
+ @SuppressWarnings("boxing")
+ private String onlineTimeFromSeconds(long totalsecs)
+ {
+ long total = totalsecs;
+ long secs = total % 60;
+ total -= secs;
+ total /= 60;
+ long mins = total % 60;
+ total -= mins;
+ total /= 60;
+ long hours = total % 24;
+ total -= hours;
+ total /= 24;
+ long days = total;
+
+ String
+ "%d days, %d hours, %d minutes, %d seconds", days, hours, mins,
+ secs);
+ return onlineTime;
+ }
+
+ // TODO is this perhaps obsolete nowadays?
+ /** Send message of the day lines to one client. */
+ public void deliverOldVersionWarning(String chatId, String userName,
+ IWebClient client)
+ {
+ long when = new Date().getTime();
+ String sender = "SYSTEM";
+ boolean isResent = false;
+
+ ArrayList<String> lines = new ArrayList<String>();
+ lines.add("");
+ lines
+ .add("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
+ lines.add("");
+ lines.add(" Hello " + userName + ", please note:");
+ lines
+ .add(" You are using a Colossus version older than 0.10.3. See message above!");
+ lines.add("");
+ lines
+ .add("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
+ lines.add("");
+
+ for (String line : lines)
+ {
+ client.chatDeliver(chatId, when, sender, line, isResent);
+ }
+ }
+
+ public void createStoreAndDeliverMessage(String sender, String message)
+ {
+ long now = new Date().getTime();
+ ChatMessage msg = new ChatMessage(this.chatId,
+ now, sender, message);
+ synchronized (storage)
+ {
+ storage.storeMessage(msg);
+ }
+ appendToChatlog(msg);
+ deliverMessage(msg, userDB);
+ }
+
+ private void deliverMessage(ChatMessage msg, UserDB userDB)
+ {
+ Collection<User> users = userDB.getLoggedInUsers();
+ for (User u : users)
+ {
+ IWebClient client = u.getWebserverClient();
+ deliverMessageToClient(msg, client, false);
+ }
+ }
+
+ private void deliverMessageToClient(ChatMessage msg, IWebClient client,
+ boolean isResent)
+ {
+ client.chatDeliver(msg.getChatId(), msg.getWhen(), msg.getSender(),
+ msg.getMessage(), isResent);
+ }
+
+ public void tellLastMessagesToOne(IWebClient client)
+ {
+ synchronized (storage)
+ {
+ for (ChatMessage msg : storage.getLastNChatMessages())
+ {
+ deliverMessageToClient(msg, client, true);
+ }
+ }
+ long now = new Date().getTime();
+ client.chatDeliver(chatId, now, null, null, true);
+ }
+
+ private PrintWriter openLogForAppend(WebServerOptions options)
+ {
+ String usersFileDirectory = options
+ .getStringOption(WebServerConstants.optDataDirectory);
+ if (usersFileDirectory == null)
+ {
+ LOGGER
+ .severe("Data Directory (for chat messages log file) is null! Define it in cf file!");
+ System.exit(1);
+ }
+ String filename = "ChatLog-" + getChannelId() + ".txt";
+
+ PrintWriter chatLog = null;
+ try
+ {
+ boolean append = true;
+ chatLog = new PrintWriter(new FileOutputStream(new File(
+ usersFileDirectory, filename), append));
+ }
+ catch (FileNotFoundException e)
+ {
+ LOGGER.log(Level.SEVERE, "Writing char messages file " + filename
+ + "failed: FileNotFoundException: ", e);
+ }
+ return chatLog;
+ }
+
+ private void appendToChatlog(ChatMessage msg)
+ {
+ String sender = msg.getSender();
+ String message = msg.getMessage();
+ long when = msg.getWhen();
+
+
+ String whenTime = whenFormatter.timeAsString(when);
+ String dateChange = whenFormatter.hasDateChanged();
+ if (dateChange != null)
+ {
+ chatLog.println(doubledashes + " " + dateChange + " "
+ + doubledashes);
+ }
+ chatLog.println(whenTime + " " + sender + ": " + message);
+ chatLog.flush();
+ }
+}
Property changes on: trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ChatChannel.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ChatMsgStorage.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ChatMsgStorage.java 2015-04-09 16:14:41 UTC (rev 5374)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/webserver/ChatMsgStorage.java 2015-04-09 16:48:13 UTC (rev 5375)
@@ -1,187 +1,187 @@
-package net.sf.colossus.webserver;
-
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import net.sf.colossus.webcommon.ChatMessage;
-
-public class ChatMsgStorage
-{
- private static final Logger LOGGER = Logger.getLogger(ChatMsgStorage.class
- .getName());
-
- private final WebServerOptions options;
- private final ChatChannel channel;
- private final List<ChatMessage> lastNChatMessages;
-
- /** Just by coincidence, we use the same separator as for the network
- * transmissions, so then there is no risk of "can't be unambiguely
- * encoded".
- */
- private final static String SEP = " ~ ";
-
- public ChatMsgStorage(ChatChannel theChannel, WebServerOptions options)
- {
- this.options = options;
- this.channel = theChannel;
- LOGGER.fine("Chat Message Storage instantiated for channel "
- + getChannel().getChannelId());
- this.lastNChatMessages = new ArrayList<ChatMessage>();
- restoreMessages();
- }
-
- public void dispose()
- {
- storeMessages();
- LOGGER.fine("disposing - stored " + lastNChatMessages.size()
- + " messages");
- }
-
- public ChatChannel getChannel()
- {
- return channel;
- }
-
- public List<ChatMessage> getLastNChatMessages()
- {
- return Collections.unmodifiableList(lastNChatMessages);
- }
-
- void storeMessage(ChatMessage msg)
- {
- List<ChatMessage> list = lastNChatMessages;
- synchronized (list)
- {
- list.add(msg);
- if (list.size() > WebServerConstants.keepLastNMessages)
- {
- // if longer than max, remove oldest one
- list.remove(0);
- }
- }
- }
-
- /** Store all messages to a permanent storage (Disk file or DB) from where
- * they can be read back when server is restarting
- */
- ...
[truncated message content] |
|
From: <cl...@us...> - 2015-04-09 16:14:44
|
Revision: 5374
http://sourceforge.net/p/colossus/code/5374
Author: cleka
Date: 2015-04-09 16:14:41 +0000 (Thu, 09 Apr 2015)
Log Message:
-----------
committing one file where property was changed
Modified Paths:
--------------
branches/properties-test/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java
Property Changed:
----------------
branches/properties-test/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java
Modified: branches/properties-test/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java
===================================================================
--- branches/properties-test/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java 2015-04-09 16:01:24 UTC (rev 5373)
+++ branches/properties-test/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java 2015-04-09 16:14:41 UTC (rev 5374)
@@ -1,21 +1,21 @@
-package net.sf.colossus.webcommon;
-
-
-import java.rmi.AccessException;
-import java.rmi.NotBoundException;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-
-public interface IGameManager extends Remote
-{
- public void tellEvent(String description) throws RemoteException;
-
- public void registerGame(String gameId) throws RemoteException,
- NotBoundException;
-
- public void unregisterGame(String gameId) throws AccessException,
- NotBoundException, RemoteException;
-}
-
-
+package net.sf.colossus.webcommon;
+
+
+import java.rmi.AccessException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+
+public interface IGameManager extends Remote
+{
+ public void tellEvent(String description) throws RemoteException;
+
+ public void registerGame(String gameId) throws RemoteException,
+ NotBoundException;
+
+ public void unregisterGame(String gameId) throws AccessException,
+ NotBoundException, RemoteException;
+}
+
+
Property changes on: branches/properties-test/core/src/main/java/net/sf/colossus/webcommon/IGameManager.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2015-04-09 16:01:35
|
Revision: 5373
http://sourceforge.net/p/colossus/code/5373
Author: cleka
Date: 2015-04-09 16:01:24 +0000 (Thu, 09 Apr 2015)
Log Message:
-----------
Making tests how to change eol settings without that all lines appear changed.
Added Paths:
-----------
branches/properties-test/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2015-02-11 21:19:53
|
Revision: 5372
http://sourceforge.net/p/colossus/code/5372
Author: cleka
Date: 2015-02-11 21:19:43 +0000 (Wed, 11 Feb 2015)
Log Message:
-----------
Added svn:eol-style on two files
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/client/ClientThread.java
Property Changed:
----------------
trunk/Colossus/core/src/main/java/net/sf/colossus/client/ClientThread.java
trunk/Colossus/core/src/main/java/net/sf/colossus/client/GameClientSide.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/ClientThread.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/client/ClientThread.java 2015-02-11 21:11:32 UTC (rev 5371)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/ClientThread.java 2015-02-11 21:19:43 UTC (rev 5372)
@@ -1,959 +1,959 @@
-package net.sf.colossus.client;
-
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import net.sf.colossus.common.Constants;
-import net.sf.colossus.game.BattlePhase;
-import net.sf.colossus.game.EntrySide;
-import net.sf.colossus.game.Legion;
-import net.sf.colossus.game.Player;
-import net.sf.colossus.game.PlayerColor;
-import net.sf.colossus.util.Glob;
-import net.sf.colossus.util.Split;
-import net.sf.colossus.variant.BattleHex;
-import net.sf.colossus.variant.CreatureType;
-import net.sf.colossus.variant.MasterHex;
-
-
-/**
- * This will be a thread that executes all the client side processing;
- * additional to the actual SocketClientThread which did that earlier.
- *
- * SCT will only handle the reading from Socket and push incoming
- * messages to a queue and return back to listening on the socket.
- * This way, it should be able to read all data in time so that no
- * data pile up, and reply to ping requests almost instantly.
- *
- * ClientThread gets most of messages to parse already via a queue.
- * Should also sending use a queue, and/or, the sending methods be
- * inside ClientThread, and SocketClientThread merely provide the
- * sendToServer method (which could be implemented differently e.g.
- * in a "send via queue, instead of via socket", for local clients)?
- *
- * @author Clemens Katzer
- */
-
-public class ClientThread extends Thread
-{
- private static final Logger LOGGER = Logger.getLogger(ClientThread.class
- .getName());
-
- private static int threadNumberCounter = 0;
-
- private final int threadNr;
-
- private final Client client;
-
- private final LinkedBlockingQueue<ServerEvent> queue;
-
- private boolean done = false;
-
- // if we enable that, things get stuck... (perhaps because logger
- // of all threads need then to get a lock on the logger too often?)
- private final boolean LOG_PROCESSING_TIMES = false;
-
-
- // this is enqueued to get the thread out of the "take()"-waiting
- private final static ServerEvent END_EVENT = new ClientThread.ServerEvent(
- 0L, "END", new ArrayList<String>());
-
-
- public ClientThread(Client client)
- {
- this.client = client;
- this.threadNr = nextThreadNumber();
-
- queue = new LinkedBlockingQueue<ServerEvent>();
- }
-
- private static synchronized int nextThreadNumber()
- {
- return ++threadNumberCounter;
- }
-
- public int getThreadNumber()
- {
- return this.threadNr;
- }
-
- public void enqueue(String method, List<String> args)
- {
- queue.offer(new ServerEvent(ClientThread.getNow(), method, args));
- }
-
- // Client checks whether still something to do from "here" before
- // switching to new connectio (after reconnect)
- public int getQueueLen()
- {
- return queue.size();
- }
-
- public void disposeQueue()
- {
- // Get thread out of it's "take" waiting
- done = true;
- boolean success = queue.offer(END_EVENT);
- if (!success)
- {
- LOGGER.warning("CT " + getName()
- + ": failed to offer END signal to queue!");
- }
- }
-
- public boolean isEngagementStartupOngoing()
- {
- return client.isEngagementStartupOngoing();
- }
-
- public void clearEngagementStartupOngoing()
- {
- client.setEngagementStartupOngoing(false);
- }
-
- public void disposeClient()
- {
- client.disposeClient();
- }
-
- public void setClosedByServer()
- {
- client.setClosedByServer();
- }
-
- public String getNameMaybe()
- {
- if (client != null && client.getOwningPlayer() != null)
- {
- return client.getOwningPlayer().getName();
- }
- else
- {
- return "<no client or no owning player name yet>";
- }
- }
-
- @Override
- public void run()
- {
- LOGGER.finest("ClientThread run() started.");
- while (!done)
- {
- ServerEvent event = null;
- try
- {
- event = queue.take();
- if (event == END_EVENT)
- {
- continue;
- }
- event.executionStarts(ClientThread.getNow());
- callMethod(event.getMethod(), event.getArgs());
- event.executionCompleted(ClientThread.getNow());
- }
- catch (InterruptedException e)
- {
- LOGGER.severe("queue.take() interrupted?!?!");
- }
-
- if (event != null)
- {
- if (LOG_PROCESSING_TIMES)
- {
- event.logProcessing();
- }
- }
- else
- {
- LOGGER.severe("null event - bailed out with exception??");
- }
-
- }
- LOGGER.finest("ClientThread run() ending.");
- }
-
- public void notifyUserIfGameIsPaused(String message)
- {
- if (client.isPaused())
- {
- LOGGER.info("Game in \"Pause\" state - "
- + "sending message anyway.");
- if (!message.startsWith(Constants.replyToPing))
- {
- client.showMessageDialog("NOTE: Game is paused "
- + "- server will not confirm/react to any of\n"
- + "your GUI activities (move, split, ...), and thus "
- + "they will not show effect on the Board yet!");
- }
- }
- }
-
- public void notifyThatNotConnected()
- {
- client.notifyThatNotConnected();
- }
-
- public void appendToConnectionLog(String s)
- {
- client.appendToConnectionLog(s);
- }
-
- static int _MAXLEN = 80;
-
- private void callMethod(String method, List<String> args)
- {
- if (client != null && !client.getOwningPlayer().isAI()
- && client.isFightPhase())
- {
- String allArgs = new String();
- allArgs = Glob.glob(", ", args);
- if (_MAXLEN != 0)
- {
- int len = allArgs.length();
- if (len > _MAXLEN)
- {
- allArgs = allArgs.substring(0, _MAXLEN) + "...";
- }
- }
- if (isEngagementStartupOngoing())
- {
- client.logMsgToServer("I", "CT, message: " + method + "("
- + allArgs + ")");
- }
- LOGGER.info("CT, message: " + method + "(" + allArgs + ")");
- }
- else
- {
- LOGGER.finest("Client (CT) '" + getNameMaybe()
- + "' processing message: " + method);
- }
-
- if (method.equals(Constants.tellMovementRoll))
- {
- int roll = Integer.parseInt(args.remove(0));
- client.tellMovementRoll(roll);
- }
- else if (method.equals(Constants.syncOption))
- {
- String optname = args.remove(0);
- String value = args.remove(0);
- client.syncOption(optname, value);
- }
- else if (method.equals(Constants.updatePlayerInfo))
- {
- List<String> infoStrings = Split.split(Glob.sep, args.remove(0));
- client.updatePlayerInfo(infoStrings);
- }
- else if (method.equals(Constants.setColor))
- {
- String colorName = args.remove(0);
- client.setColor(PlayerColor.getByName(colorName));
- }
- else if (method.equals(Constants.updateCreatureCount))
- {
- String creatureName = args.remove(0);
- int count = Integer.parseInt(args.remove(0));
- int deadCount = Integer.parseInt(args.remove(0));
- client.updateCreatureCount(resolveCreatureType(creatureName),
- count, deadCount);
- }
- else if (method.equals(Constants.removeLegion))
- {
- String id = args.remove(0);
- client.removeLegion(resolveLegion(id));
- }
- else if (method.equals(Constants.setLegionStatus))
- {
- String markerId = args.remove(0);
- boolean moved = Boolean.valueOf(args.remove(0)).booleanValue();
- boolean teleported = Boolean.valueOf(args.remove(0))
- .booleanValue();
- int entrySideId = Integer.parseInt(args.remove(0));
- String lastRecruit = args.remove(0);
- client.setLegionStatus(resolveLegion(markerId), moved, teleported,
- EntrySide.values()[entrySideId],
- resolveCreatureType(lastRecruit));
- }
- else if (method.equals(Constants.addCreature))
- {
- String markerId = args.remove(0);
- String name = args.remove(0);
- String reason = args.isEmpty() ? "<Unknown>" : args.remove(0);
- client.addCreature(resolveLegion(markerId),
- resolveCreatureType(name), reason);
- }
- else if (method.equals(Constants.removeCreature))
- {
- String markerId = args.remove(0);
- String name = args.remove(0);
- String reason = args.isEmpty() ? "<Unknown>" : args.remove(0);
- client.removeCreature(resolveLegion(markerId),
- resolveCreatureType(name), reason);
- }
- else if (method.equals(Constants.revealCreatures))
- {
- String markerId = args.remove(0);
- String namesString = args.remove(0);
- List<String> names = Split.split(Glob.sep, namesString);
-
- // safeguard against getting empty string list from server
- // TODO: should split be fixed instead??
- if (namesString.equals("") && names.size() > 0
- && names.get(0).equals(""))
- {
- names.remove(0);
- }
- String reason = args.isEmpty() ? "<Unknown>" : args.remove(0);
- Player player = client.getGameClientSide().getPlayerByMarkerId(
- markerId);
- Legion legion;
- if (player.hasLegion(markerId))
- {
- legion = player.getLegionByMarkerId(markerId);
- }
- else
- {
- // this can happen on game startup since there is no explicit
- // event creating the first legions
- // TODO try to make this less implicit
- assert client.getTurnNumber() == -1 : "Implicit legion creation should happen only "
- + "before the first round";
- legion = new LegionClientSide(player, markerId, player
- .getStartingTower());
- player.addLegion(legion);
- }
- List<CreatureType> creatures = new ArrayList<CreatureType>();
- for (String name : names)
- {
- creatures.add(resolveCreatureType(name));
- }
- client.revealCreatures(legion, creatures, reason);
- }
- else if (method.equals(Constants.revealEngagedCreatures))
- {
- String markerId = args.remove(0);
- boolean isAttacker = Boolean.valueOf(args.remove(0))
- .booleanValue();
- String names = args.remove(0);
- String reason = args.isEmpty() ? "<Unknown>" : args.remove(0);
- client.revealEngagedCreatures(resolveLegion(markerId),
- resolveCreatureTypes(names), isAttacker, reason);
- }
- else if (method.equals(Constants.removeDeadBattleChits))
- {
- client.removeDeadBattleChits();
- }
- else if (method.equals(Constants.placeNewChit))
- {
- clearEngagementStartupOngoing();
- String imageName = args.remove(0);
- boolean inverted = Boolean.valueOf(args.remove(0)).booleanValue();
- int tag = Integer.parseInt(args.remove(0));
- String hexLabel = args.remove(0);
- BattleHex hex = resolveBattleHex(hexLabel);
- client.placeNewChit(imageName, inverted, tag, hex);
- }
- else if (method.equals(Constants.replayOngoing))
- {
- boolean val = Boolean.valueOf(args.remove(0)).booleanValue();
- // older servers may not send this...
- // TODO obsolete... nowadays they do, and there are other,
- // incompatiblities added since then...
- String turnArgMaybe = args.isEmpty() ? "0" : args.remove(0);
- int maxTurn = Integer.parseInt(turnArgMaybe);
- client.tellReplay(val, maxTurn);
- }
- else if (method.equals(Constants.redoOngoing))
- {
- boolean val = Boolean.valueOf(args.remove(0)).booleanValue();
- client.tellRedo(val);
- }
- else if (method.equals(Constants.initBoard))
- {
- client.initBoard();
- }
- else if (method.equals(Constants.setPlayerName))
- {
- String playerName = args.remove(0);
- client.setPlayerName(playerName);
- }
- else if (method.equals(Constants.createSummonAngel))
- {
- String markerId = args.remove(0);
- client.createSummonAngel(resolveLegion(markerId));
- }
- else if (method.equals(Constants.askAcquireAngel))
- {
- String markerId = args.remove(0);
- List<CreatureType> recruits = resolveCreatureTypes(args.remove(0));
- client.askAcquireAngel(resolveLegion(markerId), recruits);
- }
- else if (method.equals(Constants.askChooseStrikePenalty))
- {
- List<String> choices = Split.split(Glob.sep, args.remove(0));
- client.askChooseStrikePenalty(choices);
- }
- else if (method.equals(Constants.tellGameOver))
- {
- String message = args.remove(0);
- boolean disposeFollows = false;
- if (!args.isEmpty())
- {
- disposeFollows = Boolean.valueOf(args.remove(0))
- .booleanValue();
- }
- client.tellGameOver(message, disposeFollows);
- }
- else if (method.equals(Constants.tellPlayerElim))
- {
- String playerName = args.remove(0);
- String slayerName = args.remove(0);
- // TODO use the "noone" player instead of null if no slayer?
- client.tellPlayerElim(client.getPlayerByName(playerName),
- slayerName.equals("null") ? null : (client.getGameClientSide()
- .getPlayerByName(slayerName)));
- }
- else if (method.equals(Constants.askConcede))
- {
- String allyMarkerId = args.remove(0);
- String enemyMarkerId = args.remove(0);
- client.askConcede(resolveLegion(allyMarkerId),
- resolveLegion(enemyMarkerId));
- }
- else if (method.equals(Constants.askFlee))
- {
- String allyMarkerId = args.remove(0);
- String enemyMarkerId = args.remove(0);
- client.askFlee(resolveLegion(allyMarkerId),
- resolveLegion(enemyMarkerId));
- }
- else if (method.equals(Constants.askNegotiate))
- {
- String attackerId = args.remove(0);
- String defenderId = args.remove(0);
- client.askNegotiate(resolveLegion(attackerId),
- resolveLegion(defenderId));
- }
- else if (method.equals(Constants.tellProposal))
- {
- String proposalString = args.remove(0);
- client.tellProposal(proposalString);
- }
- else if (method.equals(Constants.tellSlowResults))
- {
- int targetTag = Integer.parseInt(args.remove(0));
- int slowValue = Integer.parseInt(args.remove(0));
- client.tellSlowResults(targetTag, slowValue);
- }
- else if (method.equals(Constants.tellStrikeResults))
- {
- int strikerTag = Integer.parseInt(args.remove(0));
- int targetTag = Integer.parseInt(args.remove(0));
- int strikeNumber = Integer.parseInt(args.remove(0));
- List<String> rolls = Split.split(Glob.sep, args.remove(0));
- int damage = Integer.parseInt(args.remove(0));
- boolean killed = Boolean.valueOf(args.remove(0)).booleanValue();
- boolean wasCarry = Boolean.valueOf(args.remove(0)).booleanValue();
- int carryDamageLeft = Integer.parseInt(args.remove(0));
-
- Set<String> carryTargetDescriptions = new HashSet<String>();
- if (!args.isEmpty())
- {
- String buf = args.remove(0);
- if (buf != null && buf.length() > 0)
- {
- List<String> ctdList = Split.split(Glob.sep, buf);
- carryTargetDescriptions.addAll(ctdList);
- }
- }
-
- client.tellStrikeResults(strikerTag, targetTag, strikeNumber,
- rolls, damage, killed, wasCarry, carryDamageLeft,
- carryTargetDescriptions);
- }
- else if (method.equals(Constants.initBattle))
- {
- String masterHexLabel = args.remove(0);
- int battleTurnNumber = Integer.parseInt(args.remove(0));
- String battleActivePlayerName = args.remove(0);
- BattlePhase battlePhase = BattlePhase.values()[Integer
- .parseInt(args.remove(0))];
- String attackerMarkerId = args.remove(0);
- String defenderMarkerId = args.remove(0);
- client.initBattle(resolveHex(masterHexLabel), battleTurnNumber,
- client.getPlayerByName(battleActivePlayerName), battlePhase,
- resolveLegion(attackerMarkerId),
- resolveLegion(defenderMarkerId));
- }
- else if (method.equals(Constants.cleanupBattle))
- {
- client.cleanupBattle();
- }
- else if (method.equals(Constants.nextEngagement))
- {
- client.nextEngagement();
- }
- else if (method.equals(Constants.doReinforce))
- {
- String markerId = args.remove(0);
- client.doReinforce(resolveLegion(markerId));
- }
- else if (method.equals(Constants.didRecruit))
- {
- String markerId = args.remove(0);
- String recruitName = args.remove(0);
- String recruiterName = args.remove(0);
- int numRecruiters = Integer.parseInt(args.remove(0));
- client.didRecruit(resolveLegion(markerId),
- resolveCreatureType(recruitName),
- resolveCreatureType(recruiterName), numRecruiters);
- }
- else if (method.equals(Constants.undidRecruit))
- {
- String markerId = args.remove(0);
- String recruitName = args.remove(0);
- client.undidRecruit(resolveLegion(markerId),
- resolveCreatureType(recruitName));
- }
- else if (method.equals(Constants.setupTurnState))
- {
- String activePlayerName = args.remove(0);
- int turnNumber = Integer.parseInt(args.remove(0));
- client.setupTurnState(client.getPlayerByName(activePlayerName),
- turnNumber);
- }
- else if (method.equals(Constants.setupSplit))
- {
- String activePlayerName = args.remove(0);
- int turnNumber = Integer.parseInt(args.remove(0));
- client.setupSplit(client.getPlayerByName(activePlayerName),
- turnNumber);
- }
- else if (method.equals(Constants.setupMove))
- {
- client.setupMove();
- }
- else if (method.equals(Constants.setupFight))
- {
- client.setupFight();
- }
- else if (method.equals(Constants.setupMuster))
- {
- client.setupMuster();
- }
- else if (method.equals(Constants.kickPhase))
- {
- client.kickPhase();
- }
-
- else if (method.equals(Constants.setupBattleSummon))
- {
- String battleActivePlayerName = args.remove(0);
- int battleTurnNumber = Integer.parseInt(args.remove(0));
- client.setupBattleSummon(client
- .getPlayerByName(battleActivePlayerName), battleTurnNumber);
- }
- else if (method.equals(Constants.setupBattleRecruit))
- {
- String battleActivePlayerName = args.remove(0);
- int battleTurnNumber = Integer.parseInt(args.remove(0));
- client.setupBattleRecruit(client
- .getPlayerByName(battleActivePlayerName), battleTurnNumber);
- }
- else if (method.equals(Constants.setupBattleMove))
- {
- String battleActivePlayerName = args.remove(0);
- int battleTurnNumber = Integer.parseInt(args.remove(0));
- client.setupBattleMove(client
- .getPlayerByName(battleActivePlayerName), battleTurnNumber);
- }
- else if (method.equals(Constants.setupBattleFight))
- {
- BattlePhase battlePhase = BattlePhase.values()[Integer
- .parseInt(args.remove(0))];
- String battleActivePlayerName = args.remove(0);
- client.setupBattleFight(battlePhase, client
- .getPlayerByName(battleActivePlayerName));
- }
- else if (method.equals(Constants.tellLegionLocation))
- {
- String markerId = args.remove(0);
- String hexLabel = args.remove(0);
- client.tellLegionLocation(resolveLegion(markerId),
- resolveHex(hexLabel));
- }
- else if (method.equals(Constants.tellBattleMove))
- {
- int tag = Integer.parseInt(args.remove(0));
- String startingHexLabel = args.remove(0);
- String endingHexLabel = args.remove(0);
- boolean undo = Boolean.valueOf(args.remove(0)).booleanValue();
- BattleHex startingHex = resolveBattleHex(startingHexLabel);
- BattleHex endingHex = resolveBattleHex(endingHexLabel);
- client.tellBattleMove(tag, startingHex, endingHex, undo);
- }
- else if (method.equals(Constants.didMove))
- {
- String markerId = args.remove(0);
- String startingHexLabel = args.remove(0);
- String currentHexLabel = args.remove(0);
- String entrySideLabel = args.remove(0);
- boolean teleport = Boolean.valueOf(args.remove(0)).booleanValue();
- // servers from older versions might not send this arg
- String teleportingLord = null;
- if (!args.isEmpty())
- {
- teleportingLord = args.remove(0);
- if (teleportingLord.equals("null"))
- {
- teleportingLord = null;
- }
- }
- boolean splitLegionHasForcedMove = false;
- // servers from older versions might not send this arg
- if (!args.isEmpty())
- {
- splitLegionHasForcedMove = Boolean.valueOf(args.remove(0))
- .booleanValue();
- }
- client
- .didMove(resolveLegion(markerId),
- resolveHex(startingHexLabel), resolveHex(currentHexLabel),
- EntrySide.fromLabel(entrySideLabel), teleport,
- resolveCreatureType(teleportingLord),
- splitLegionHasForcedMove);
- }
- else if (method.equals(Constants.undidMove))
- {
- String markerId = args.remove(0);
- String formerHexLabel = args.remove(0);
- String currentHexLabel = args.remove(0);
- boolean splitLegionHasForcedMove = false;
- // servers from older versions might not send this arg
- if (!args.isEmpty())
- {
- splitLegionHasForcedMove = Boolean.valueOf(args.remove(0))
- .booleanValue();
- }
- client.undidMove(resolveLegion(markerId),
- resolveHex(formerHexLabel), resolveHex(currentHexLabel),
- splitLegionHasForcedMove);
- }
- else if (method.equals(Constants.didSummon))
- {
- String summonerId = args.remove(0);
- String donorId = args.remove(0);
- String summon = args.remove(0);
- client.didSummon(resolveLegion(summonerId),
- resolveLegion(donorId), resolveCreatureType(summon));
- }
- else if (method.equals(Constants.undidSplit))
- {
- String splitoffId = args.remove(0);
- String survivorId = args.remove(0);
- int turn = Integer.parseInt(args.remove(0));
- client.undidSplit(resolveLegion(splitoffId),
- resolveLegion(survivorId), turn);
- }
- else if (method.equals(Constants.didSplit))
- {
- String hexLabel = args.remove(0);
- String parentId = args.remove(0);
- String childId = args.remove(0);
- int childHeight = Integer.parseInt(args.remove(0));
- List<CreatureType> splitoffs = resolveCreatureTypes(args.remove(0));
- int turn = Integer.parseInt(args.remove(0));
- // create client-side copy of new legion
- MasterHex hex = resolveHex(hexLabel);
- Legion parentLegion = resolveLegion(parentId);
- Player player = parentLegion.getPlayer();
- Legion newLegion = new LegionClientSide(player, childId, hex);
- player.addLegion(newLegion);
- client.didSplit(hex, parentLegion, newLegion, childHeight,
- splitoffs, turn);
- }
- else if (method.equals(Constants.askPickColor))
- {
- List<String> clList = Split.split(Glob.sep, args.remove(0));
- List<PlayerColor> colorsLeft = new ArrayList<PlayerColor>();
- for (String colorName : clList)
- {
- colorsLeft.add(PlayerColor.getByName(colorName));
- }
- client.askPickColor(colorsLeft);
- }
- else if (method.equals(Constants.askPickFirstMarker))
- {
- client.askPickFirstMarker();
- }
- else if (method.equals(Constants.log))
- {
- if (!args.isEmpty())
- {
- String message = args.remove(0);
- client.log(message);
- }
- }
- else if (method.equals(Constants.nak))
- {
- String reason = args.remove(0);
- String message = args.remove(0);
- // NOTE: nak for SignOn is already handled in SCT at the moment...
- client.nak(reason, message);
-
- }
- else if (method.equals(Constants.boardActive))
- {
- boolean val = Boolean.valueOf(args.remove(0)).booleanValue();
- client.setBoardActive(val);
- }
- else if (method.equals(Constants.tellEngagement))
- {
- client.tellEngagement(resolveHex(args.remove(0)), client
- .getLegion(args.remove(0)), client.getLegion(args.remove(0)));
- }
- else if (method.equals(Constants.tellEngagementResults))
- {
- String winnerId = args.remove(0);
- String resMethod = args.remove(0);
- int points = Integer.parseInt(args.remove(0));
- int turns = Integer.parseInt(args.remove(0));
- Legion legion;
- if (winnerId.equals("null"))
- {
- legion = null;
- }
- else
- {
- legion = resolveLegion(winnerId);
- }
- client.tellEngagementResults(legion, resMethod, points, turns);
- }
-
- else if (method.equals(Constants.tellWhatsHappening))
- {
- String message = args.remove(0);
- client.tellWhatsHappening(message);
- }
-
- // a popup message
- else if (method.equals(Constants.messageFromServer))
- {
- String message = args.remove(0);
- client.messageFromServer(message);
- }
-
- // just written to log (which might become visible by itself if needed)
- else if (method.equals(Constants.appendToConnectionLog))
- {
- String message = args.remove(0);
- client.appendToConnectionLog(message);
- }
-
- else if (method.equals(Constants.syncCompleted))
- {
- int syncRequestNr = Integer.parseInt(args.remove(0));
- client.tellSyncCompleted(syncRequestNr);
- }
-
- else if (method.equals(Constants.askConfirmCatchUp))
- {
- client.confirmWhenCaughtUp();
- }
-
- else if (method.equals(Constants.serverConnectionOK))
- {
- LOGGER.info("Received server connection OK message from server "
- + "for player " + getNameMaybe());
- client.serverConfirmsConnection();
- }
-
- else if (method.equals(Constants.relayedPeerRequest))
- {
- String requestingClientName = args.remove(0);
- client.relayedPeerRequest(requestingClientName);
- }
-
- else if (method.equals(Constants.relayBackReceivedMsg))
- {
- String respondingClientName = args.remove(0);
- int queueLen = Integer.parseInt(args.remove(0));
- LOGGER.info("In client " + getNameMaybe()
- + ", got back 'Received' message from client "
- + respondingClientName);
- client.peerRequestReceivedBy(respondingClientName, queueLen);
- }
-
- else if (method.equals(Constants.relayBackProcessedMsg))
- {
- String respondingClientName = args.remove(0);
- LOGGER.info("In client " + getNameMaybe()
- + ", got back 'Processed' message from client "
- + respondingClientName);
- client.peerRequestProcessedBy(respondingClientName);
- }
-
- else
- {
- LOGGER.log(Level.SEVERE, "Bogus packet (Client, method: " + method
- + ", args: " + args + ")");
- }
- LOGGER.finest("Client '" + getNameMaybe()
- + "' finished method processing");
- }
-
- private MasterHex resolveHex(String label)
- {
- MasterHex hexByLabel = client.getGame().getVariant().getMasterBoard()
- .getHexByLabel(label);
- assert hexByLabel != null : "Client got unknown hex label '" + label
- + "' from server";
- return hexByLabel;
- }
-
- private BattleHex resolveBattleHex(String hexLabel)
- {
- return client.getGame().getBattleSite().getTerrain().getHexByLabel(
- hexLabel);
- }
-
- private List<CreatureType> resolveCreatureTypes(String nameList)
- {
- List<CreatureType> creatures = new ArrayList<CreatureType>();
- if (!nameList.equals(""))
- {
- List<String> names = Split.split(Glob.sep, nameList);
- for (String creatureName : names)
- {
- creatures.add(resolveCreatureType(creatureName));
- }
- }
- return creatures;
- }
-
- private CreatureType resolveCreatureType(String creatureName)
- {
- if ((creatureName == null) || (creatureName.equals("null")))
- {
- return null;
- }
- CreatureType creatureByName = client.getGame().getVariant()
- .getCreatureByName(creatureName);
- assert creatureByName != null : "Client got unknown creature name '"
- + creatureName + "' from server";
- return creatureByName;
- }
-
- private Legion resolveLegion(String markerId)
- {
- Legion legion = client.getLegion(markerId);
-
- // it's not just "unknown" - it might also be at any point during
- // the replay of a loaded game that there is no legion for that
- // marker *at that particular moment*.
- // Whereas delayed painting in EDT may cause similar error, they
- // should be carefully distincted.
-
- if (legion == null)
- {
- // If such a thing happens, there is something seriously wrong,
- // so I don't see a use in continuing the game.
- // This I call it severe, and log it always,
- // not just an assertion.
- LOGGER.severe("CT ResolveLegion for " + markerId + " in client "
- + getNameMaybe() + " gave null!");
- }
-
- // Peter made this assertion, I guess...
- assert legion != null : "ClientThread.resolveLegion(" + markerId
- + " in client of player " + getNameMaybe() + " returned null!";
-
- return legion;
- }
-
- public static long getNow()
- {
- return new Date().getTime();
- }
-
- public static class ServerEvent
- {
- private final long received;
- private final long enqueued;
- private long executionStarted;
- private long executionCompleted;
-
- private final String method;
- private final List<String> args;
-
- public ServerEvent(long received, String method, List<String> args)
- {
- this.received = received;
- this.enqueued = ClientThread.getNow();
- this.method = method;
- this.args = new ArrayList<String>(args);
- }
-
- public String getMethod()
- {
- return method;
- }
-
- public List<String> getArgs()
- {
- return args;
- }
-
- public void executionStarts(long when)
- {
- this.executionStarted = when;
- }
-
- public long getExecutionStarted()
- {
- return this.executionStarted;
- }
-
- public void executionCompleted(long when)
- {
- this.executionCompleted = when;
- }
-
- public long getExecutionCompleted()
- {
- return this.executionCompleted;
- }
-
- public void logProcessing()
- {
- long enqueuing = enqueued - received;
- long execution = executionCompleted - executionStarted;
- long inQueue = executionStarted - enqueued;
- long processing = executionCompleted - received;
-
- Level loglevel;
- if (processing > 5000)
- {
- loglevel = Level.WARNING;
- }
- else
- {
- loglevel = Level.FINEST;
- }
- ClientThread thisThread = (ClientThread)Thread.currentThread();
- LOGGER.log(loglevel, "Event " + method + " in thread #"
- + thisThread.getThreadNumber()
- + " received at "
- + received + ": overall processing took: " + processing
- + "ms (enqueuing took " + enqueuing + "ms, inQueue " + inQueue
- + "ms, processing took " + execution + "ms)");
- }
- }
-}
+package net.sf.colossus.client;
+
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import net.sf.colossus.common.Constants;
+import net.sf.colossus.game.BattlePhase;
+import net.sf.colossus.game.EntrySide;
+import net.sf.colossus.game.Legion;
+import net.sf.colossus.game.Player;
+import net.sf.colossus.game.PlayerColor;
+import net.sf.colossus.util.Glob;
+import net.sf.colossus.util.Split;
+import net.sf.colossus.variant.BattleHex;
+import net.sf.colossus.variant.CreatureType;
+import net.sf.colossus.variant.MasterHex;
+
+
+/**
+ * This will be a thread that executes all the client side processing;
+ * additional to the actual SocketClientThread which did that earlier.
+ *
+ * SCT will only handle the reading from Socket and push incoming
+ * messages to a queue and return back to listening on the socket.
+ * This way, it should be able to read all data in time so that no
+ * data pile up, and reply to ping requests almost instantly.
+ *
+ * ClientThread gets most of messages to parse already via a queue.
+ * Should also sending use a queue, and/or, the sending methods be
+ * inside ClientThread, and SocketClientThread merely provide the
+ * sendToServer method (which could be implemented differently e.g.
+ * in a "send via queue, instead of via socket", for local clients)?
+ *
+ * @author Clemens Katzer
+ */
+
+public class ClientThread extends Thread
+{
+ private static final Logger LOGGER = Logger.getLogger(ClientThread.class
+ .getName());
+
+ private static int threadNumberCounter = 0;
+
+ private final int threadNr;
+
+ private final Client client;
+
+ private final LinkedBlockingQueue<ServerEvent> queue;
+
+ private boolean done = false;
+
+ // if we enable that, things get stuck... (perhaps because logger
+ // of all threads need then to get a lock on the logger too often?)
+ private final boolean LOG_PROCESSING_TIMES = false;
+
+
+ // this is enqueued to get the thread out of the "take()"-waiting
+ private final static ServerEvent END_EVENT = new ClientThread.ServerEvent(
+ 0L, "END", new ArrayList<String>());
+
+
+ public ClientThread(Client client)
+ {
+ this.client = client;
+ this.threadNr = nextThreadNumber();
+
+ queue = new LinkedBlockingQueue<ServerEvent>();
+ }
+
+ private static synchronized int nextThreadNumber()
+ {
+ return ++threadNumberCounter;
+ }
+
+ public int getThreadNumber()
+ {
+ return this.threadNr;
+ }
+
+ public void enqueue(String method, List<String> args)
+ {
+ queue.offer(new ServerEvent(ClientThread.getNow(), method, args));
+ }
+
+ // Client checks whether still something to do from "here" before
+ // switching to new connectio (after reconnect)
+ public int getQueueLen()
+ {
+ return queue.size();
+ }
+
+ public void disposeQueue()
+ {
+ // Get thread out of it's "take" waiting
+ done = true;
+ boolean success = queue.offer(END_EVENT);
+ if (!success)
+ {
+ LOGGER.warning("CT " + getName()
+ + ": failed to offer END signal to queue!");
+ }
+ }
+
+ public boolean isEngagementStartupOngoing()
+ {
+ return client.isEngagementStartupOngoing();
+ }
+
+ public void clearEngagementStartupOngoing()
+ {
+ client.setEngagementStartupOngoing(false);
+ }
+
+ public void disposeClient()
+ {
+ client.disposeClient();
+ }
+
+ public void setClosedByServer()
+ {
+ client.setClosedByServer();
+ }
+
+ public String getNameMaybe()
+ {
+ if (client != null && client.getOwningPlayer() != null)
+ {
+ return client.getOwningPlayer().getName();
+ }
+ else
+ {
+ return "<no client or no owning player name yet>";
+ }
+ }
+
+ @Override
+ public void run()
+ {
+ LOGGER.finest("ClientThread run() started.");
+ while (!done)
+ {
+ ServerEvent event = null;
+ try
+ {
+ event = queue.take();
+ if (event == END_EVENT)
+ {
+ continue;
+ }
+ event.executionStarts(ClientThread.getNow());
+ callMethod(event.getMethod(), event.getArgs());
+ event.executionCompleted(ClientThread.getNow());
+ }
+ catch (InterruptedException e)
+ {
+ LOGGER.severe("queue.take() interrupted?!?!");
+ }
+
+ if (event != null)
+ {
+ if (LOG_PROCESSING_TIMES)
+ {
+ event.logProcessing();
+ }
+ }
+ else
+ {
+ LOGGER.severe("null event - bailed out with exception??");
+ }
+
+ }
+ LOGGER.finest("ClientThread run() ending.");
+ }
+
+ public void notifyUserIfGameIsPaused(String message)
+ {
+ if (client.isPaused())
+ {
+ LOGGER.info("Game in \"Pause\" state - "
+ + "sending message anyway.");
+ if (!message.startsWith(Constants.replyToPing))
+ {
+ client.showMessageDialog("NOTE: Game is paused "
+ + "- server will not confirm/react to any of\n"
+ + "your GUI activities (move, split, ...), and thus "
+ + "they will not show effect on the Board yet!");
+ }
+ }
+ }
+
+ public void notifyThatNotConnected()
+ {
+ client.notifyThatNotConnected();
+ }
+
+ public void appendToConnectionLog(String s)
+ {
+ client.appendToConnectionLog(s);
+ }
+
+ static int _MAXLEN = 80;
+
+ private void callMethod(String method, List<String> args)
+ {
+ if (client != null && !client.getOwningPlayer().isAI()
+ && client.isFightPhase())
+ {
+ String allArgs = new String();
+ allArgs = Glob.glob(", ", args);
+ if (_MAXLEN != 0)
+ {
+ int len = allArgs.length();
+ if (len > _MAXLEN)
+ {
+ allArgs = allArgs.substring(0, _MAXLEN) + "...";
+ }
+ }
+ if (isEngagementStartupOngoing())
+ {
+ client.logMsgToServer("I", "CT, message: " + method + "("
+ + allArgs + ")");
+ }
+ LOGGER.info("CT, message: " + method + "(" + allArgs + ")");
+ }
+ else
+ {
+ LOGGER.finest("Client (CT) '" + getNameMaybe()
+ + "' processing message: " + method);
+ }
+
+ if (method.equals(Constants.tellMovementRoll))
+ {
+ int roll = Integer.parseInt(args.remove(0));
+ client.tellMovementRoll(roll);
+ }
+ else if (method.equals(Constants.syncOption))
+ {
+ String optname = args.remove(0);
+ String value = args.remove(0);
+ client.syncOption(optname, value);
+ }
+ else if (method.equals(Constants.updatePlayerInfo))
+ {
+ List<String> infoStrings = Split.split(Glob.sep, args.remove(0));
+ client.updatePlayerInfo(infoStrings);
+ }
+ else if (method.equals(Constants.setColor))
+ {
+ String colorName = args.remove(0);
+ client.setColor(PlayerColor.getByName(colorName));
+ }
+ else if (method.equals(Constants.updateCreatureCount))
+ {
+ String creatureName = args.remove(0);
+ int count = Integer.parseInt(args.remove(0));
+ int deadCount = Integer.parseInt(args.remove(0));
+ client.updateCreatureCount(resolveCreatureType(creatureName),
+ count, deadCount);
+ }
+ else if (method.equals(Constants.removeLegion))
+ {
+ String id = args.remove(0);
+ client.removeLegion(resolveLegion(id));
+ }
+ else if (method.equals(Constants.setLegionStatus))
+ {
+ String markerId = args.remove(0);
+ boolean moved = Boolean.valueOf(args.remove(0)).booleanValue();
+ boolean teleported = Boolean.valueOf(args.remove(0))
+ .booleanValue();
+ int entrySideId = Integer.parseInt(args.remove(0));
+ String lastRecruit = args.remove(0);
+ client.setLegionStatus(resolveLegion(markerId), moved, teleported,
+ EntrySide.values()[entrySideId],
+ resolveCreatureType(lastRecruit));
+ }
+ else if (method.equals(Constants.addCreature))
+ {
+ String markerId = args.remove(0);
+ String name = args.remove(0);
+ String reason = args.isEmpty() ? "<Unknown>" : args.remove(0);
+ client.addCreature(resolveLegion(markerId),
+ resolveCreatureType(name), reason);
+ }
+ else if (method.equals(Constants.removeCreature))
+ {
+ String markerId = args.remove(0);
+ String name = args.remove(0);
+ String reason = args.isEmpty() ? "<Unknown>" : args.remove(0);
+ client.removeCreature(resolveLegion(markerId),
+ resolveCreatureType(name), reason);
+ }
+ else if (method.equals(Constants.revealCreatures))
+ {
+ String markerId = args.remove(0);
+ String namesString = args.remove(0);
+ List<String> names = Split.split(Glob.sep, namesString);
+
+ // safeguard against getting empty string list from server
+ // TODO: should split be fixed instead??
+ if (namesString.equals("") && names.size() > 0
+ && names.get(0).equals(""))
+ {
+ names.remove(0);
+ }
+ String reason = args.isEmpty() ? "<Unknown>" : args.remove(0);
+ Player player = client.getGameClientSide().getPlayerByMarkerId(
+ markerId);
+ Legion legion;
+ if (player.hasLegion(markerId))
+ {
+ legion = player.getLegionByMarkerId(markerId);
+ }
+ else
+ {
+ // this can happen on game startup since there is no explicit
+ // event creating the first legions
+ // TODO try to make this less implicit
+ assert client.getTurnNumber() == -1 : "Implicit legion creation should happen only "
+ + "before the first round";
+ legion = new LegionClientSide(player, markerId, player
+ .getStartingTower());
+ player.addLegion(legion);
+ }
+ List<CreatureType> creatures = new ArrayList<CreatureType>();
+ for (String name : names)
+ {
+ creatures.add(resolveCreatureType(name));
+ }
+ client.revealCreatures(legion, creatures, reason);
+ }
+ else if (method.equals(Constants.revealEngagedCreatures))
+ {
+ String markerId = args.remove(0);
+ boolean isAttacker = Boolean.valueOf(args.remove(0))
+ .booleanValue();
+ String names = args.remove(0);
+ String reason = args.isEmpty() ? "<Unknown>" : args.remove(0);
+ client.revealEngagedCreatures(resolveLegion(markerId),
+ resolveCreatureTypes(names), isAttacker, reason);
+ }
+ else if (method.equals(Constants.removeDeadBattleChits))
+ {
+ client.removeDeadBattleChits();
+ }
+ else if (method.equals(Constants.placeNewChit))
+ {
+ clearEngagementStartupOngoing();
+ String imageName = args.remove(0);
+ boolean inverted = Boolean.valueOf(args.remove(0)).booleanValue();
+ int tag = Integer.parseInt(args.remove(0));
+ String hexLabel = args.remove(0);
+ BattleHex hex = resolveBattleHex(hexLabel);
+ client.placeNewChit(imageName, inverted, tag, hex);
+ }
+ else if (method.equals(Constants.replayOngoing))
+ {
+ boolean val = Boolean.valueOf(args.remove(0)).booleanValue();
+ // older servers may not send this...
+ // TODO obsolete... nowadays they do, and there are other,
+ // incompatiblities added since then...
+ String turnArgMaybe = args.isEmpty() ? "0" : args.remove(0);
+ int maxTurn = Integer.parseInt(turnArgMaybe);
+ client.tellReplay(val, maxTurn);
+ }
+ else if (method.equals(Constants.redoOngoing))
+ {
+ boolean val = Boolean.valueOf(args.remove(0)).booleanValue();
+ client.tellRedo(val);
+ }
+ else if (method.equals(Constants.initBoard))
+ {
+ client.initBoard();
+ }
+ else if (method.equals(Constants.setPlayerName))
+ {
+ String playerName = args.remove(0);
+ client.setPlayerName(playerName);
+ }
+ else if (method.equals(Constants.createSummonAngel))
+ {
+ String markerId = args.remove(0);
+ client.createSummonAngel(resolveLegion(markerId));
+ }
+ else if (method.equals(Constants.askAcquireAngel))
+ {
+ String markerId = args.remove(0);
+ List<CreatureType> recruits = resolveCreatureTypes(args.remove(0));
+ client.askAcquireAngel(resolveLegion(markerId), recruits);
+ }
+ else if (method.equals(Constants.askChooseStrikePenalty))
+ {
+ List<String> choices = Split.split(Glob.sep, args.remove(0));
+ client.askChooseStrikePenalty(choices);
+ }
+ else if (method.equals(Constants.tellGameOver))
+ {
+ String message = args.remove(0);
+ boolean disposeFollows = false;
+ if (!args.isEmpty())
+ {
+ disposeFollows = Boolean.valueOf(args.remove(0))
+ .booleanValue();
+ }
+ client.tellGameOver(message, disposeFollows);
+ }
+ else if (method.equals(Constants.tellPlayerElim))
+ {
+ String playerName = args.remove(0);
+ String slayerName = args.remove(0);
+ // TODO use the "noone" player instead of null if no slayer?
+ client.tellPlayerElim(client.getPlayerByName(playerName),
+ slayerName.equals("null") ? null : (client.getGameClientSide()
+ .getPlayerByName(slayerName)));
+ }
+ else if (method.equals(Constants.askConcede))
+ {
+ String allyMarkerId = args.remove(0);
+ String enemyMarkerId = args.remove(0);
+ client.askConcede(resolveLegion(allyMarkerId),
+ resolveLegion(enemyMarkerId));
+ }
+ else if (method.equals(Constants.askFlee))
+ {
+ String allyMarkerId = args.remove(0);
+ String enemyMarkerId = args.remove(0);
+ client.askFlee(resolveLegion(allyMarkerId),
+ resolveLegion(enemyMarkerId));
+ }
+ else if (method.equals(Constants.askNegotiate))
+ {
+ String attackerId = args.remove(0);
+ String defenderId = args.remove(0);
+ client.askNegotiate(resolveLegion(attackerId),
+ resolveLegion(defenderId));
+ }
+ else if (method.equals(Constants.tellProposal))
+ {
+ String proposalString = args.remove(0);
+ client.tellProposal(proposalString);
+ }
+ else if (method.equals(Constants.tellSlowResults))
+ {
+ int targetTag = Integer.parseInt(args.remove(0));
+ int slowValue = Integer.parseInt(args.remove(0));
+ client.tellSlowResults(targetTag, slowValue);
+ }
+ else if (method.equals(Constants.tellStrikeResults))
+ {
+ int strikerTag = Integer.parseInt(args.remove(0));
+ int targetTag = Integer.parseInt(args.remove(0));
+ int strikeNumber = Integer.parseInt(args.remove(0));
+ List<String> rolls = Split.split(Glob.sep, args.remove(0));
+ int damage = Integer.parseInt(args.remove(0));
+ boolean killed = Boolean.valueOf(args.remove(0)).booleanValue();
+ boolean wasCarry = Boolean.valueOf(args.remove(0)).booleanValue();
+ int carryDamageLeft = Integer.parseInt(args.remove(0));
+
+ Set<String> carryTargetDescriptions = new HashSet<String>();
+ if (!args.isEmpty())
+ {
+ String buf = args.remove(0);
+ if (buf != null && buf.length() > 0)
+ {
+ List<String> ctdList = Split.split(Glob.sep, buf);
+ carryTargetDescriptions.addAll(ctdList);
+ }
+ }
+
+ client.tellStrikeResults(strikerTag, targetTag, strikeNumber,
+ rolls, damage, killed, wasCarry, carryDamageLeft,
+ carryTargetDescriptions);
+ }
+ else if (method.equals(Constants.initBattle))
+ {
+ String masterHexLabel = args.remove(0);
+ int battleTurnNumber = Integer.parseInt(args.remove(0));
+ String battleActivePlayerName = args.remove(0);
+ BattlePhase battlePhase = BattlePhase.values()[Integer
+ .parseInt(args.remove(0))];
+ String attackerMarkerId = args.remove(0);
+ String defenderMarkerId = args.remove(0);
+ client.initBattle(resolveHex(masterHexLabel), battleTurnNumber,
+ client.getPlayerByName(battleActivePlayerName), battlePhase,
+ resolveLegion(attackerMarkerId),
+ resolveLegion(defenderMarkerId));
+ }
+ else if (method.equals(Constants.cleanupBattle))
+ {
+ client.cleanupBattle();
+ }
+ else if (method.equals(Constants.nextEngagement))
+ {
+ client.nextEngagement();
+ }
+ else if (method.equals(Constants.doReinforce))
+ {
+ String markerId = args.remove(0);
+ client.doReinforce(resolveLegion(markerId));
+ }
+ else if (method.equals(Constants.didRecruit))
+ {
+ String markerId = args.remove(0);
+ String recruitName = args.remove(0);
+ String recruiterName = args.remove(0);
+ int numRecruiters = Integer.parseInt(args.remove(0));
+ client.didRecruit(resolveLegion(markerId),
+ resolveCreatureType(recruitName),
+ resolveCreatureType(recruiterName), numRecruiters);
+ }
+ else if (method.equals(Constants.undidRecruit))
+ {
+ String markerId = args.remove(0);
+ String recruitName = args.remove(0);
+ client.undidRecruit(resolveLegion(markerId),
+ resolveCreatureType(recruitName));
+ }
+ else if (method.equals(Constants.setupTurnState))
+ {
+ String activePlayerName = args.remove(0);
+ int turnNumber = Integer.parseInt(args.remove(0));
+ client.setupTurnState(client.getPlayerByName(activePlayerName),
+ turnNumber);
+ }
+ else if (method.equals(Constants.setupSplit))
+ {
+ String activePlayerName = args.remove(0);
+ int turnNumber = Integer.parseInt(args.remove(0));
+ client.setupSplit(client.getPlayerByName(activePlayerName),
+ turnNumber);
+ }
+ else if (method.equals(Constants.setupMove))
+ {
+ client.setupMove();
+ }
+ else if (method.equals(Constants.setupFight))
+ {
+ client.setupFight();
+ }
+ else if (method.equals(Constants.setupMuster))
+ {
+ client.setupMuster();
+ }
+ else if (method.equals(Constants.kickPhase))
+ {
+ client.kickPhase();
+ }
+
+ else if (method.equals(Constants.setupBattleSummon))
+ {
+ String battleActivePlayerName = args.remove(0);
+ int battleTurnNumber = Integer.parseInt(args.remove(0));
+ client.setupBattleSummon(client
+ .getPlayerByName(battleActivePlayerName), battleTurnNumber);
+ }
+ else if (method.equals(Constants.setupBattleRecruit))
+ {
+ String battleActivePlayerName = args.remove(0);
+ int battleTurnNumber = Integer.parseInt(args.remove(0));
+ client.setupBattleRecruit(client
+ .getPlayerByName(battleActivePlayerName), battleTurnNumber);
+ }
+ else if (method.equals(Constants.setupBattleMove))
+ {
+ String battleActivePlayerName = args.remove(0);
+ int battleTurnNumber = Integer.parseInt(args.remove(0));
+ client.setupBattleMove(client
+ .getPlayerByName(battleActivePlayerName), battleTurnNumber);
+ }
+ else if (method.equals(Constants.setupBattleFight))
+ {
+ BattlePhase battlePhase = BattlePhase.values()[Integer
+ .parseInt(args.remove(0))];
+ String battleActivePlayerName = args.remove(0);
+ client.setupBattleFight(battlePhase, client
+ .getPlayerByName(battleActivePlayerName));
+ }
+ else if (method.equals(Constants.tellLegionLocation))
+ {
+ String markerId = args.remove(0);
+ String hexLabel = args.remove(0);
+ client.tellLegionLocation(resolveLegion(markerId),
+ resolveHex(hexLabel));
+ }
+ else if (method.equals(Constants.tellBattleMove))
+ {
+ int tag = Integer.parseInt(args.remove(0));
+ String startingHexLabel = args.remove(0);
+ String endingHexLabel = args.remove(0);
+ boolean undo = Boolean.valueOf(args.remove(0)).booleanValue();
+ BattleHex startingHex = resolveBattleHex(startingHexLabel);
+ BattleHex endingHex = resolveBattleHex(endingHexLabel);
+ client.tellBattleMove(tag, startingHex, endingHex, undo);
+ }
+ else if (method.equals(Constants.didMove))
+ {
+ String markerId = args.remove(0);
+ String startingHexLabel = args.remove(0);
+ String currentHexLabel = args.remove(0);
+ String entrySideLabel = args.remove(0);
+ boolean teleport = Boolean.valueOf(args.remove(0)).booleanValue();
+ // servers from older versions might not send this arg
+ String teleportingLord = null;
+ if (!args.isEmpty())
+ {
+ teleportingLord = args.remove(0);
+ if (teleportingLord.equals("null"))
+ {
+ teleportingLord = null;
+ }
+ }
+ boolean splitLegionHasForcedMove = false;
+ // servers from older versions might not send this arg
+ if (!args.isEmpty())
+ {
+ splitLegionHasForcedMove = Boolean.valueOf(args.remove(0))
+ .booleanValue();
+ }
+ client
+ .didMove(resolveLegion(markerId),
+ resolveHex(startingHexLabel), resolveHex(currentHexLabel),
+ EntrySide.fromLabel(entrySideLabel), teleport,
+ resolveCreatureType(teleportingLord),
+ splitLegionHasForcedMove);
+ }
+ else if (method.equals(Constants.undidMove))
+ {
+ String markerId = args.remove(0);
+ String formerH...
[truncated message content] |
|
From: <cl...@us...> - 2015-02-11 21:11:40
|
Revision: 5371
http://sourceforge.net/p/colossus/code/5371
Author: cleka
Date: 2015-02-11 21:11:32 +0000 (Wed, 11 Feb 2015)
Log Message:
-----------
Added a "request response from all other clients" connection test:
Only basics. for example no displaying of response in "easy form". Server does not check yet whether client could handle the requests.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java
trunk/Colossus/core/src/main/java/net/sf/colossus/client/ClientThread.java
trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java
trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java
trunk/Colossus/core/src/main/java/net/sf/colossus/common/Constants.java
trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java
trunk/Colossus/core/src/main/java/net/sf/colossus/gui/MasterBoard.java
trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java
trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java
trunk/Colossus/core/src/main/java/net/sf/colossus/server/IServer.java
trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2015-02-11 17:31:46 UTC (rev 5370)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2015-02-11 21:11:32 UTC (rev 5371)
@@ -742,6 +742,19 @@
server.checkServerConnection();
}
+ public void doCheckAllConnections(String requestingClientName)
+ {
+ server.checkAllConnections(requestingClientName);
+ }
+
+ public void relayedPeerRequest(String requestingClientName)
+ {
+ LOGGER.finest("In client " + this.owningPlayer.getName()
+ + " we received, that peer " + requestingClientName
+ + " requests a reply.");
+ server.peerRequestProcessed(requestingClientName);
+ }
+
/** Upon request with checkServerConnection, server sends a confirmation.
* This method here processes the confirmation.
*/
@@ -750,6 +763,18 @@
gui.serverConfirmsConnection();
}
+ public void peerRequestReceivedBy(String respondingPlayerName, int queueLen)
+ {
+ LOGGER.info("Got RECEIVED confirmation from "
+ + respondingPlayerName + ", queueLen=" + queueLen);
+ }
+
+ public void peerRequestProcessedBy(String respondingPlayerName)
+ {
+ LOGGER.info("Got PROCESSED confirmation from "
+ + respondingPlayerName);
+ }
+
public void locallyInitiateSaveGame(String filename)
{
localServer.initiateSaveGame(filename);
@@ -1564,6 +1589,11 @@
server.clientConfirmedCatchup();
}
+ public void confirmRelayedPeerRequest(String requestingClientName)
+ {
+ server.peerRequestProcessed(requestingClientName);
+ }
+
public void initBoard()
{
// SyncOptions is now done, so now we can create movement and
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/ClientThread.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/client/ClientThread.java 2015-02-11 17:31:46 UTC (rev 5370)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/ClientThread.java 2015-02-11 21:11:32 UTC (rev 5371)
@@ -775,6 +775,31 @@
client.serverConfirmsConnection();
}
+ else if (method.equals(Constants.relayedPeerRequest))
+ {
+ String requestingClientName = args.remove(0);
+ client.relayedPeerRequest(requestingClientName);
+ }
+
+ else if (method.equals(Constants.relayBackReceivedMsg))
+ {
+ String respondingClientName = args.remove(0);
+ int queueLen = Integer.parseInt(args.remove(0));
+ LOGGER.info("In client " + getNameMaybe()
+ + ", got back 'Received' message from client "
+ + respondingClientName);
+ client.peerRequestReceivedBy(respondingClientName, queueLen);
+ }
+
+ else if (method.equals(Constants.relayBackProcessedMsg))
+ {
+ String respondingClientName = args.remove(0);
+ LOGGER.info("In client " + getNameMaybe()
+ + ", got back 'Processed' message from client "
+ + respondingClientName);
+ client.peerRequestProcessedBy(respondingClientName);
+ }
+
else
{
LOGGER.log(Level.SEVERE, "Bogus packet (Client, method: " + method
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2015-02-11 17:31:46 UTC (rev 5370)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2015-02-11 21:11:32 UTC (rev 5371)
@@ -73,6 +73,12 @@
public void serverConfirmsConnection();
+ public void relayedPeerRequest(String requestingClientName);
+
+ public void peerRequestReceivedBy(String respondingPlayerName, int queueLen);
+
+ public void peerRequestProcessedBy(String respondingPlayerName);
+
public void setPlayerName(String newPlayerName);
public void createSummonAngel(Legion legion);
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2015-02-11 17:31:46 UTC (rev 5370)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2015-02-11 21:11:32 UTC (rev 5371)
@@ -900,6 +900,16 @@
goingDown = true;
}
+ else if (method.equals(Constants.relayedPeerRequest))
+ {
+ String requestingClientName = args.get(0);
+ int queueLen = clientThread.getQueueLen();
+ peerRequestReceived(requestingClientName, queueLen);
+ // in this one, both the socket reading thread and the actual
+ // client are supposed to respond.
+ clientThread.enqueue(method, args);
+ }
+
else if (method.equals(Constants.nak) && args.size() > 0
&& args.get(0) != null && args.get(0).equals("SignOn"))
{
@@ -1199,6 +1209,12 @@
sendToServer(Constants.checkConnection);
}
+ public void checkAllConnections(String requestingClientName)
+ {
+ sendToServer(Constants.checkAllConnections + sep
+ + requestingClientName);
+ }
+
public void clientConfirmedCatchup()
{
sendToServer(Constants.catchupConfirmation);
@@ -1225,6 +1241,18 @@
+ syncCounter);
}
+ public void peerRequestReceived(String requestingClientName, int queueLen)
+ {
+ sendToServer(Constants.peerRequestReceived + sep
+ + requestingClientName + sep + queueLen);
+ }
+
+ public void peerRequestProcessed(String requestingClientName)
+ {
+ sendToServer(Constants.peerRequestProcessed + sep
+ + requestingClientName);
+ }
+
public void replyToPing(int requestNr, long requestSent, long requestReceived)
{
out.println(Constants.replyToPing + sep + requestNr + sep
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/common/Constants.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/common/Constants.java 2015-02-11 17:31:46 UTC (rev 5370)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/common/Constants.java 2015-02-11 21:11:32 UTC (rev 5371)
@@ -191,6 +191,8 @@
public static final String quitGame = "Quit Application";
public static final String closeBoard = "Close MasterBoard";
public static final String checkConnection = "Check connection";
+ public static final String checkAllConnections = "Check all connections";
+ public static final String peerRequestsConfirmation = "Peer requests confirmation";
public static final String cleanDisconnect = "Disconnect";
public static final String tryReconnect = "Reconnect";
public static final String enforcedDisconnectByServer = "Fake Disconnect (by server)";
@@ -271,8 +273,12 @@
public static final String askPickFirstMarker = "askPickFirstMarker";
public static final String catchupConfirmation = "catchupConfirmation";
public static final String serverConnectionOK = "serverConnectionOK";
+ public static final String relayBackReceivedMsg = "relayBackReceivedMsg";
+ public static final String relayBackProcessedMsg = "relayBackProcessedMsg";
public static final String pingRequest = "pingRequest";
public static final String replyToPing = "replyToPing";
+ public static final String peerRequestReceived = "peerRequestReceived";
+ public static final String peerRequestProcessed = "peerRequestProcessed";
public static final String requestSyncDelta = "requestSyncDelta";
public static final String confirmCommitPoint = "confirmCommitPoint";
public static final String logMsgToServer = "logMsgToServer";
@@ -361,6 +367,7 @@
public static final String nak = "nak";
public static final String boardActive = "boardActive";
public static final String askConfirmCatchUp = "askConfirmCatchUp";
+ public static final String relayedPeerRequest = "relayedPeerRequest";
public static final String gameInitInfo = "gameInitInfo";
public static final String commitPoint = "commitPoint";
public static final String messageFromServer = "messageFromServer";
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java 2015-02-11 17:31:46 UTC (rev 5370)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java 2015-02-11 21:11:32 UTC (rev 5371)
@@ -769,6 +769,58 @@
}
}
+ /** When user requests it from File menu, this method here
+ * requests the server to send requests to all clients, and
+ * returns their responses to us.
+ */
+ void checkAllConnections()
+ {
+ logPerhaps("checkAllServerConnections()");
+ if (client.isSctAlreadyDown())
+ {
+ JOptionPane.showMessageDialog(getMapOrBoardFrame(),
+ "No point to request 'all connections check' - we know already that "
+ + " the socket connection is in 'down' state!",
+ "Useless attempt to check connection",
+ JOptionPane.INFORMATION_MESSAGE);
+
+ return;
+ }
+
+ Runnable checker = new Runnable()
+ {
+ public void run()
+ {
+ synchronized (connectionCheckMutex)
+ {
+ initiateAllConnectionsCheck();
+ }
+ }
+ };
+ new Thread(checker).start();
+ }
+
+ private void initiateAllConnectionsCheck()
+ {
+ logPerhaps("initiateAllConnectionsCheck()");
+ /*
+ connectionCheckTimer = new Timer(1000 * CONN_CHECK_TIMEOUT,
+
+ new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ timeoutAbortsConnectionCheck();
+ }
+ });
+ lastConnectionCheckPackageSent = new Date().getTime();
+ connectionCheckTimer.start();
+ */
+ LOGGER.info("Client for player " + getOwningPlayer().getName()
+ + " requesting response from all clients (sending request)");
+ client.doCheckAllConnections(getOwningPlayerName());
+ }
+
private void doSetWhatToDoNext(WhatToDoNext whatToDoNext,
boolean triggerQuitTimer)
{
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/gui/MasterBoard.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/gui/MasterBoard.java 2015-02-11 17:31:46 UTC (rev 5370)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/gui/MasterBoard.java 2015-02-11 21:11:32 UTC (rev 5371)
@@ -39,8 +39,8 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
-import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
@@ -209,6 +209,7 @@
private AbstractAction enforcedDisconnectByServerAction;
private AbstractAction tryReconnectAction;
private AbstractAction checkConnectionAction;
+ private AbstractAction checkAllConnectionsAction;
private AbstractAction clearRecruitChitsAction;
private AbstractAction skipLegionAction;
@@ -988,6 +989,15 @@
}
};
+ checkAllConnectionsAction = new AbstractAction(
+ Constants.checkAllConnections)
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ gui.checkAllConnections();
+ }
+ };
+
chooseScreenAction = new AbstractAction(chooseScreen)
{
public void actionPerformed(ActionEvent e)
@@ -1228,6 +1238,9 @@
mi = fileMenu.add(checkConnectionAction);
mi.setMnemonic(KeyEvent.VK_K);
+ mi = fileMenu.add(checkAllConnectionsAction);
+ mi.setMnemonic(KeyEvent.VK_X);
+
/* Removed for r-0.13.2, since it does not work - it merely makes the
* client stop processing stuff from the queue, but ClientSocketThread
* keeps receiving and ack'ing lines from/to server.
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java 2015-02-11 17:31:46 UTC (rev 5370)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java 2015-02-11 21:11:32 UTC (rev 5371)
@@ -1007,6 +1007,25 @@
server.checkServerConnection();
}
+ else if (method.equals(Constants.peerRequestReceived))
+ {
+ String respondingClientName = args.remove(0);
+ int queueLen = Integer.parseInt(args.remove(0));
+ server.peerRequestReceived(respondingClientName, queueLen);
+ }
+
+ else if (method.equals(Constants.peerRequestProcessed))
+ {
+ String respondingClientName = args.remove(0);
+ server.peerRequestProcessed(respondingClientName);
+ }
+
+ else if (method.equals(Constants.checkAllConnections))
+ {
+ String requestingClientName = args.remove(0);
+ server.checkAllConnections(requestingClientName);
+ }
+
else if (method.equals(Constants.requestSyncDelta))
{
int lastReceivedMsgNr = Integer.parseInt(args.remove(0));
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java 2015-02-11 17:31:46 UTC (rev 5370)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java 2015-02-11 21:11:32 UTC (rev 5371)
@@ -607,6 +607,34 @@
sendToClient(Constants.serverConnectionOK);
}
+ /* One client has asked for connnection confirmation; here server
+ * relays this to each client.
+ */
+ public void relayedPeerRequest(String requestingClientName)
+ {
+ LOGGER.info("Relaying peerRequest from client "
+ + requestingClientName + " to client " + getClientName());
+ sendToClient(Constants.relayedPeerRequest + sep + requestingClientName);
+ }
+
+ /* Relay the "received" response back to requester */
+ public void peerRequestReceivedBy(String respondingClientName, int queueLen)
+ {
+ LOGGER.info("Relaying back the received message of client "
+ + getClientName() + " to " + respondingClientName);
+ sendToClient(Constants.relayBackReceivedMsg + sep
+ + respondingClientName + sep + queueLen);
+ }
+
+ /* Relay the "processed" response back to requester */
+ public void peerRequestProcessedBy(String respondingClientName)
+ {
+ LOGGER.info("Relaying back the processed message of client "
+ + getClientName() + " to " + respondingClientName);
+ sendToClient(Constants.relayBackProcessedMsg + sep
+ + respondingClientName);
+ }
+
public void pingRequest(long requestSent)
{
if (canHandlePingRequest())
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/IServer.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/IServer.java 2015-02-11 17:31:46 UTC (rev 5370)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/IServer.java 2015-02-11 21:11:32 UTC (rev 5371)
@@ -126,6 +126,12 @@
public void checkServerConnection();
+ public void checkAllConnections(String requestingClientName);
+
+ public void peerRequestReceived(String requestingClientName, int queueLen);
+
+ public void peerRequestProcessed(String requestingClientName);
+
public void clientConfirmedCatchup();
public void joinGame(String playerName);
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2015-02-11 17:31:46 UTC (rev 5370)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2015-02-11 21:11:32 UTC (rev 5371)
@@ -3443,6 +3443,42 @@
}
}
+ public void checkAllConnections(String requestingClientName)
+ {
+ LOGGER.info("Server received checkAllConnections request from "
+ + "client " + getPlayerName() + " - ....");
+
+ // processingCH.serverConfirmsConnection();
+ // if (Constants.USE_RECORDER)
+ // {
+ // recorder.printMessagesToConsole(processingCH);
+ // }
+
+ Iterator<IClient> it = iClients.iterator();
+ while (it.hasNext())
+ {
+
+ IClient client = it.next();
+ ClientHandler reqCH = getClientHandlerByName(requestingClientName);
+ if (reqCH != client)
+ {
+ client.relayedPeerRequest(requestingClientName);
+ }
+ }
+ }
+
+ public void peerRequestReceived(String requestingClientName, int queueLen)
+ {
+ ClientHandler reqCH = getClientHandlerByName(requestingClientName);
+ reqCH.peerRequestReceivedBy(getPlayerName(), queueLen);
+ }
+
+ public void peerRequestProcessed(String requestingClientName)
+ {
+ ClientHandler reqCH = getClientHandlerByName(requestingClientName);
+ reqCH.peerRequestProcessedBy(getPlayerName());
+ }
+
private final HashSet<IClient> waitingToCatchup = new HashSet<IClient>();
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2015-02-11 17:31:53
|
Revision: 5370
http://sourceforge.net/p/colossus/code/5370
Author: cleka
Date: 2015-02-11 17:31:46 +0000 (Wed, 11 Feb 2015)
Log Message:
-----------
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/appmain/GetPlayers.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/appmain/GetPlayers.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/appmain/GetPlayers.java 2015-02-08 15:39:41 UTC (rev 5369)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/appmain/GetPlayers.java 2015-02-11 17:31:46 UTC (rev 5370)
@@ -16,8 +16,6 @@
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;
@@ -172,7 +170,11 @@
}
serveAtPortBox = new JComboBox(sPortChoices
.toArray(new String[sPortChoices.size()]));
- serveAtPortBox.setEditable(true);
+ /* moved further down; when run here it hangs up for a minute or
+ * so in Java7 ?
+ */
+ // serveAtPortBox.setEditable(true);
+
serveAtPortBox.setSelectedItem("" + stPort);
serveAtPortBox.addActionListener(new ActionListener()
{
@@ -545,6 +547,8 @@
});
setVisible(true);
+ serveAtPortBox.setEditable(true);
+
WelcomeDialog.showWelcomeDialogMaybe(options);
}
@@ -599,23 +603,14 @@
private void setRunningOnLabel(int port)
{
- InetAddress ia = null;
- String hostString = "<unknown>";
- try
- {
- ia = InetAddress.getLocalHost();
- hostString = ia.toString();
- }
- catch (UnknownHostException ex)
- {
- // In this case the UHExc. is not that a serious problem, because
- // it's for the displaying in GUI only.
- LOGGER.log(Level.WARNING, ex.toString(), ex);
- }
+ /* 11.2.2015: Removed the "on host" part, because with Java 7
+ * under certain circumstances the InetAdress.getLocalHostname()
+ * might be stuck a minute or so, before it times out.
+ */
String runningOnString = "Running Colossus Version "
+ BuildInfo.getReleaseVersion() + " (revision "
- + BuildInfo.getRevisionInfoString() + ") on " + hostString
- + ", port " + port;
+ + BuildInfo.getRevisionInfoString() + ")" + ", listening at port "
+ + port;
runningOnLabel.setText(runningOnString);
}
@@ -751,7 +746,8 @@
}
final JComboBox playerName = new JComboBox(nameChoices);
- playerName.setEditable(true);
+ // setEditable moved to enablePlayers; if done here, it
+ // was hanging for 1 minutes or so.
onePlayerPane.add(playerName);
playerName.addActionListener(new ActionListener()
{
@@ -786,6 +782,7 @@
{
playerTypes[i].setEnabled(i < maxPlayers);
playerNames[i].setEnabled(i < maxPlayers);
+ playerNames[i].setEditable(true);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2015-02-08 15:39:43
|
Revision: 5369
http://sourceforge.net/p/colossus/code/5369
Author: cleka
Date: 2015-02-08 15:39:41 +0000 (Sun, 08 Feb 2015)
Log Message:
-----------
Do resurrectImmortals() now in GSS.finishBattle().
This should fix the bug that Angels and Warlock killed in battle or during dead player legion cleanup, should not be available for recruiting/acquiring at end of this battle.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java
trunk/Colossus/core/src/main/java/net/sf/colossus/server/LegionServerSide.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java 2013-12-22 18:47:01 UTC (rev 5368)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java 2015-02-08 15:39:41 UTC (rev 5369)
@@ -2356,6 +2356,8 @@
}
}
battleInProgress = false;
+ getCaretaker().resurrectImmortals();
+ updateCaretakerDisplays();
setEngagementResult(Constants.erMethodFight, battleWinner, points,
turnDone);
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/LegionServerSide.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/LegionServerSide.java 2013-12-22 18:47:01 UTC (rev 5368)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/LegionServerSide.java 2015-02-08 15:39:41 UTC (rev 5369)
@@ -262,8 +262,10 @@
game.getCaretaker().resurrectImmortals();
}
*/
- game.getCaretaker().resurrectImmortals();
+ // 8.2.2015: Moved to GameServerSide.finishBattle()
+ // game.getCaretaker().resurrectImmortals();
+
// Let the clients clean up the legion marker, etc.
if (updateHistory)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-12-22 18:47:03
|
Revision: 5368
http://sourceforge.net/p/colossus/code/5368
Author: cleka
Date: 2013-12-22 18:47:01 +0000 (Sun, 22 Dec 2013)
Log Message:
-----------
Created .gitignore in Colossus top level dir
Added Paths:
-----------
trunk/Colossus/.gitignore
Added: trunk/Colossus/.gitignore
===================================================================
--- trunk/Colossus/.gitignore (rev 0)
+++ trunk/Colossus/.gitignore 2013-12-22 18:47:01 UTC (rev 5368)
@@ -0,0 +1 @@
+build
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-11-10 11:46:56
|
Revision: 5367
http://sourceforge.net/p/colossus/code/5367
Author: cleka
Date: 2013-11-10 11:46:53 +0000 (Sun, 10 Nov 2013)
Log Message:
-----------
Change loglevel info to finer for "Last ping round is 30 secs ago..."
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2013-11-09 19:51:07 UTC (rev 5366)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2013-11-10 11:46:53 UTC (rev 5367)
@@ -2052,7 +2052,7 @@
if (now - lastPingRound > 1000 * PING_REQUEST_INTERVAL_SEC)
{
long ago = (now - lastPingRound) / 1000;
- LOGGER.info("Last ping round is " + ago
+ LOGGER.finer("Last ping round is " + ago
+ " secs ago - doing another.");
lastPingRound = now;
for (ClientHandler client : realClients)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-11-09 19:51:11
|
Revision: 5366
http://sourceforge.net/p/colossus/code/5366
Author: cleka
Date: 2013-11-09 19:51:07 +0000 (Sat, 09 Nov 2013)
Log Message:
-----------
Get rid of two Eclipse warnings.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/server/MessageRecorder.java
trunk/Colossus/core/src/main/java/net/sf/colossus/util/StaticResourceLoader.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/MessageRecorder.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/MessageRecorder.java 2013-11-01 20:26:30 UTC (rev 5365)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/MessageRecorder.java 2013-11-09 19:51:07 UTC (rev 5366)
@@ -84,6 +84,7 @@
return message;
}
+ @SuppressWarnings("unused")
public String getCommand()
{
return command;
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/util/StaticResourceLoader.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/util/StaticResourceLoader.java 2013-11-01 20:26:30 UTC (rev 5365)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/util/StaticResourceLoader.java 2013-11-09 19:51:07 UTC (rev 5366)
@@ -72,11 +72,6 @@
super(parent);
}
- ColossusClassLoader()
- {
- super();
- }
-
@Override
public Class<?> findClass(String className)
throws ClassNotFoundException
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-11-01 20:26:36
|
Revision: 5365
http://sourceforge.net/p/colossus/code/5365
Author: cleka
Date: 2013-11-01 20:26:30 +0000 (Fri, 01 Nov 2013)
Log Message:
-----------
Added to pingRequests counter and times when sent, received, replied.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java
trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java
trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java
trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java
trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java
trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2013-11-01 20:18:17 UTC (rev 5364)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/Client.java 2013-11-01 20:26:30 UTC (rev 5365)
@@ -3682,7 +3682,7 @@
LOGGER.log(Level.INFO, message);
}
- public void pingRequest()
+ public void pingRequest(long requestTime)
{
// Dummy, SocketClientThread handles this already.
}
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2013-11-01 20:18:17 UTC (rev 5364)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClient.java 2013-11-01 20:26:30 UTC (rev 5365)
@@ -172,7 +172,7 @@
public void setBoardActive(boolean val);
- public void pingRequest();
+ public void pingRequest(long requestTime);
public void messageFromServer(String message);
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2013-11-01 20:18:17 UTC (rev 5364)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2013-11-01 20:26:30 UTC (rev 5365)
@@ -12,6 +12,7 @@
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -827,14 +828,25 @@
{
if (method.equals(Constants.pingRequest))
{
- LOGGER.fine("SCT " + getName()
- + "received ping request from server");
- replyToPing();
+ long requestReceived = new Date().getTime();
+ int requestNr = -1;
+ long requestSent = -1L;
+
+ if (args.size() >= 2)
+ {
+ requestNr = Integer.parseInt(args.remove(0));
+ requestSent = Long.parseLong(args.remove(0));
+ }
+ LOGGER.fine("SCT " + getName() + " received ping request #"
+ + requestNr + " from server");
+
+ replyToPing(requestNr, requestSent, requestReceived);
if (clientThread != null
&& clientThread.isEngagementStartupOngoing())
{
int len = clientThread.getQueueLen();
- logMsgToServer("I", "ClientThread queue length is " + len);
+ logMsgToServer("I", "PingRequest #" + requestNr
+ + ": ClientThread queue length is " + len);
}
}
else if (method.equals(Constants.commitPoint))
@@ -924,7 +936,8 @@
}
else if (message.startsWith(Constants.replyToPing))
{
- // silently ignore
+ // silently ignore;
+ // replyToPing method(s) write directly to socket.
}
else
{
@@ -1212,9 +1225,10 @@
+ syncCounter);
}
- public void replyToPing()
+ public void replyToPing(int requestNr, long requestSent, long requestReceived)
{
- out.println(Constants.replyToPing);
+ out.println(Constants.replyToPing + sep + requestNr + sep
+ + requestSent + sep + requestReceived);
// sendToServer(Constants.replyToPing);
}
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java 2013-11-01 20:18:17 UTC (rev 5364)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java 2013-11-01 20:26:30 UTC (rev 5365)
@@ -1027,7 +1027,19 @@
else if (method.equals(Constants.replyToPing))
{
lastPingReplyReceived = new Date().getTime();
- server.replyToPing(playerName);
+ long replyReceived = lastPingReplyReceived;
+ if (args.size() >= 3)
+ {
+ int requestNr = Integer.parseInt(args.remove(0));
+ long requestSent = Long.parseLong(args.remove(0));
+ long replySent = Long.parseLong(args.remove(0));
+ server.replyToPing(playerName, requestNr, requestSent,
+ replySent, replyReceived);
+ }
+ else
+ {
+ server.replyToPing(playerName, 0, 0L, 0L, replyReceived);
+ }
}
else if (method.equals(Constants.confirmCommitPoint))
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java 2013-11-01 20:18:17 UTC (rev 5364)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java 2013-11-01 20:26:30 UTC (rev 5365)
@@ -43,6 +43,8 @@
protected int messageCounter = 0;
protected boolean isCommitPoint = false;
+ protected long pingRequestCounter = 1;
+
protected final ArrayList<MessageForClient> redoQueue = new ArrayList<MessageForClient>(
100);
@@ -605,11 +607,13 @@
sendToClient(Constants.serverConnectionOK);
}
- public void pingRequest()
+ public void pingRequest(long requestSent)
{
if (canHandlePingRequest())
{
- sendToClient(Constants.pingRequest);
+ sendToClient(Constants.pingRequest + sep + pingRequestCounter
+ + sep + requestSent);
+ pingRequestCounter++;
}
}
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2013-11-01 20:18:17 UTC (rev 5364)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2013-11-01 20:26:30 UTC (rev 5365)
@@ -11,6 +11,7 @@
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -2058,7 +2059,7 @@
{
if (!client.isTemporarilyInTrouble())
{
- client.pingRequest();
+ client.pingRequest(now);
}
}
}
@@ -3518,12 +3519,23 @@
}
}
- void replyToPing(String playerName)
+ private String prettyTime(long when)
{
- LOGGER.fine("Client " + playerName
- + " replied to ping request - fine!");
+ if (when == 0L)
+ {
+ return "n/a";
+ }
+ return new SimpleDateFormat("HH:mm:ss.SSS").format(new Date(when));
}
+ void replyToPing(String playerName, int requestNr, long requestSent,
+ long replySent, long replyReceived)
+ {
+ LOGGER.info("Ping Reply #" + requestNr + " from " + playerName + ": "
+ + prettyTime(requestSent) + "/" + prettyTime(replySent) + "/"
+ + prettyTime(replyReceived));
+ }
+
/** Used to change a player name after color is assigned. */
void setPlayerName(Player player, String newName)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-11-01 20:18:20
|
Revision: 5364
http://sourceforge.net/p/colossus/code/5364
Author: cleka
Date: 2013-11-01 20:18:17 +0000 (Fri, 01 Nov 2013)
Log Message:
-----------
Deactivate the detailed ClientGui logging. Also removed the following empty lines.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java 2013-11-01 18:15:06 UTC (rev 5363)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java 2013-11-01 20:18:17 UTC (rev 5364)
@@ -61,6 +61,8 @@
private static final Logger LOGGER = Logger.getLogger(ClientGUI.class
.getName());
+ private final boolean LOG_CG = false;
+
/* This is a number of seconds to wait for connection check
* confirmation message before assuming connection is broken and
* displaying a message telling so.
@@ -262,13 +264,19 @@
}
}
+ public void logPerhaps(String message)
+ {
+ if (LOG_CG)
+ {
+ LOGGER.fine("CG: " + message);
+ }
+ }
+
public void initBoard()
{
- LOGGER.info("CG: initBoard()");
-
+ logPerhaps("initBoard()");
String viewModeName = options.getStringOption(Options.viewMode);
viewMode = options.getNumberForViewMode(viewModeName);
-
String rcMode = options
.getStringOption(Options.showRecruitChitsSubmenu);
@@ -331,8 +339,7 @@
public void actOnGameStartingFailed()
{
- LOGGER.info("CG: actOnGameStartingFailed()");
-
+ logPerhaps("actOnGameStartingFailed()");
if (webClient != null)
{
webClient.notifyComingUp(false);
@@ -344,8 +351,7 @@
*/
private void ensureEdtSetupClientGUI()
{
- LOGGER.info("CG: ensureEdtSetupClientGUI()");
-
+ logPerhaps("ensureEdtSetupClientGUI()");
if (SwingUtilities.isEventDispatchThread())
{
setupClientGUI();
@@ -382,8 +388,7 @@
*/
public void setupClientGUI()
{
- LOGGER.info("CG: setupClientGUI()");
-
+ logPerhaps("setupClientGUI()");
/*
disposeEventViewer();
disposePreferencesWindow();
@@ -423,8 +428,7 @@
public void setChosenDevice(GraphicsDevice chosen)
{
- LOGGER.info("CG: setChosenDevice(GraphicsDevice chosen)");
-
+ logPerhaps("setChosenDevice(GraphicsDevice chosen)");
if (chosen != null)
{
secondaryParent = new JFrame(chosen.getDefaultConfiguration());
@@ -438,8 +442,7 @@
private void ensureEdtNewBattleBoard()
{
- LOGGER.info("CG: ensureEdtNewBattleBoard()");
-
+ logPerhaps("ensureEdtNewBattleBoard()");
if (SwingUtilities.isEventDispatchThread())
{
doNewBattleBoard();
@@ -483,15 +486,13 @@
public void actOnInitBattle()
{
- LOGGER.info("CG: actOnInitBattle()");
-
+ logPerhaps("actOnInitBattle()");
ensureEdtNewBattleBoard();
}
private void doNewBattleBoard()
{
- LOGGER.info("CG: doNewBattleBoard()");
-
+ logPerhaps("doNewBattleBoard()");
if (battleBoard != null)
{
LOGGER.warning("Old BattleBoard still in place? Disposing it.");
@@ -503,9 +504,8 @@
public void setStrikeNumbers(BattleUnit striker, Set<BattleHex> targetHexes)
{
- LOGGER.info("CG: setStrikeNumbers(BattleUnit striker, "
+ logPerhaps("setStrikeNumbers(BattleUnit striker, "
+ "Set<BattleHex> targetHexes)");
-
for (BattleHex targetHex : targetHexes)
{
GUIBattleChit targetChit = getGUIBattleChit(targetHex);
@@ -519,8 +519,7 @@
/** reset all strike numbers on chits */
public void resetStrikeNumbers()
{
- LOGGER.info("CG: resetStrikeNumbers()");
-
+ logPerhaps("resetStrikeNumbers()");
for (GUIBattleChit battleChit : getGUIBattleChits())
{
battleChit.setStrikeNumber(0);
@@ -533,8 +532,7 @@
public void updateStatusScreen()
{
- LOGGER.info("CG: updateStatusScreen()");
-
+ logPerhaps("updateStatusScreen()");
if (client.getNumPlayers() < 1)
{
// Called too early.
@@ -575,8 +573,7 @@
public void menuCloseBoard()
{
- LOGGER.info("CG: menuCloseBoard()");
-
+ logPerhaps("menuCloseBoard()");
clearUndoStack();
doSetWhatToDoNext(WhatToDoNext.GET_PLAYERS_DIALOG, false);
client.disposeClientOriginated();
@@ -584,7 +581,7 @@
public void menuQuitGame()
{
- LOGGER.info("CG: menuQuitGame()");
+ logPerhaps("menuQuitGame()");
// Note that if this called from webclient, webclient has already
// beforehand called client to set webclient to null :)
@@ -615,7 +612,7 @@
// Used now only by MasterBoard
void askNewCloseQuitCancel(JFrame frame, boolean fromBattleBoard)
{
- LOGGER.info("CG: askNewCloseQuitCancel(JFrame frame, "
+ logPerhaps("askNewCloseQuitCancel(JFrame frame, "
+ "boolean fromBattleBoard)");
String[] dialogOptions = new String[4];
@@ -663,8 +660,7 @@
*/
void checkServerConnection()
{
- LOGGER.info("CG: checkServerConnection()");
-
+ logPerhaps("checkServerConnection()");
if (client.isSctAlreadyDown())
{
JOptionPane.showMessageDialog(getMapOrBoardFrame(),
@@ -691,8 +687,7 @@
private void initiateConnectionCheck()
{
- LOGGER.info("CG: initiateConnectionCheck()");
-
+ logPerhaps("initiateConnectionCheck()");
connectionCheckTimer = new Timer(1000 * CONN_CHECK_TIMEOUT,
new ActionListener()
{
@@ -711,8 +706,7 @@
public void serverConfirmsConnection()
{
- LOGGER.info("CG: serverConfirmsConnection()");
-
+ logPerhaps("serverConfirmsConnection()");
synchronized (connectionCheckMutex)
{
LOGGER.info("Client for player " + getOwningPlayer().getName()
@@ -723,8 +717,7 @@
public void timeoutAbortsConnectionCheck()
{
- LOGGER.info("CG: timeoutAbortsConnectionCheck()");
-
+ logPerhaps("timeoutAbortsConnectionCheck()");
synchronized (connectionCheckMutex)
{
LOGGER.info("Client for player " + getOwningPlayer().getName()
@@ -743,8 +736,7 @@
*/
private void finishServerConnectionCheck(boolean success)
{
- LOGGER.info("CG: finishServerConnectionCheck(boolean success)");
-
+ logPerhaps("finishServerConnectionCheck(boolean success)");
if (connectionCheckTimer == null)
{
// race - the other one came nearly same time, and comes now
@@ -780,25 +772,22 @@
private void doSetWhatToDoNext(WhatToDoNext whatToDoNext,
boolean triggerQuitTimer)
{
- LOGGER.info("CG: doSetWhatToDoNext(WhatToDoNext whatToDoNext, "
+ logPerhaps("doSetWhatToDoNext(WhatToDoNext whatToDoNext, "
+ "boolean triggerQuitTimer)");
-
whatNextManager.setWhatToDoNext(whatToDoNext, triggerQuitTimer);
}
private void doSetWhatToDoNext(WhatToDoNext whatToDoNext, String loadFile)
{
- LOGGER.info("CG: doSetWhatToDoNext(WhatToDoNext whatToDoNext, "
+ logPerhaps("doSetWhatToDoNext(WhatToDoNext whatToDoNext, "
+ "String loadFile)");
-
whatNextManager.setWhatToDoNext(whatToDoNext, loadFile, true);
}
// Used by File=>Close and Window closing
private void setWhatToDoNextForClose()
{
- LOGGER.info("CG: setWhatToDoNextForClose()");
-
+ logPerhaps("setWhatToDoNextForClose()");
if (startedByWebClient)
{
doSetWhatToDoNext(WhatToDoNext.START_WEB_CLIENT, false);
@@ -816,8 +805,7 @@
public void menuNewGame()
{
- LOGGER.info("CG: menuNewGame()");
-
+ logPerhaps("menuNewGame()");
if (webClient != null)
{
webClient.dispose();
@@ -829,8 +817,7 @@
public void menuLoadGame(String filename)
{
- LOGGER.info("CG: menuLoadGame(String filename)");
-
+ logPerhaps("menuLoadGame(String filename)");
if (webClient != null)
{
webClient.dispose();
@@ -865,8 +852,7 @@
private void setupPlayerLabel()
{
- LOGGER.info("CG: setupPlayerLabel()");
-
+ logPerhaps("setupPlayerLabel()");
if (board != null)
{
board.setupPlayerLabel();
@@ -875,8 +861,7 @@
public void highlightEngagements()
{
- LOGGER.info("CG: highlightEngagements()");
-
+ logPerhaps("highlightEngagements()");
if (isMyTurn())
{
board.maybeRequestFocusAndToFront();
@@ -922,8 +907,7 @@
private void setupGUIOptionListeners()
{
- LOGGER.info("CG: setupGUIOptionListeners()");
-
+ logPerhaps("setupGUIOptionListeners()");
GUIHex.setAntialias(options.getOption(Options.antialias));
options.addListener(Options.antialias, new IOptions.Listener()
{
@@ -1134,8 +1118,7 @@
*/
private void initEventViewer()
{
- LOGGER.info("CG: initEventViewer()");
-
+ logPerhaps("initEventViewer()");
if (eventViewer == null)
{
JFrame parent = getPreferredParent();
@@ -1145,8 +1128,7 @@
public void eventViewerSetVisibleMaybe()
{
- LOGGER.info("CG: eventViewerSetVisibleMaybe()");
-
+ logPerhaps("eventViewerSetVisibleMaybe()");
// if null: no board (not yet, or not at all) => no eventviewer
if (eventViewer != null)
{
@@ -1157,8 +1139,7 @@
public void autoInspectorSetDubiousAsBlanks(boolean newValue)
{
- LOGGER.info("CG: autoInspectorSetDubiousAsBlanks(boolean newValue)");
-
+ logPerhaps("autoInspectorSetDubiousAsBlanks(boolean newValue)");
if (autoInspector != null)
{
autoInspector.setDubiousAsBlanks(newValue);
@@ -1167,8 +1148,7 @@
public void engagementResultsMaybeShow()
{
- LOGGER.info("CG: engagementResultsMaybeShow()");
-
+ logPerhaps("engagementResultsMaybeShow()");
// maybeShow decides by itself based on the current value
// of the option whether to hide or show.
// null if called too early by optionListener when loading options
@@ -1239,8 +1219,7 @@
public void actOnDidSplitPart2(MasterHex hex)
{
- LOGGER.info("CG: actOnDidSplitPart2(MasterHex hex)");
-
+ logPerhaps("actOnDidSplitPart2(MasterHex hex)");
if (client.getTurnNumber() == 1 && isMyTurn())
{
board.enableDoneAction();
@@ -1256,16 +1235,14 @@
public void actOnDoneWithMoves()
{
- LOGGER.info("CG: actOnDoneWithMoves()");
-
+ logPerhaps("actOnDoneWithMoves()");
board.clearRecruitedChits();
board.clearPossibleRecruitChits();
}
public void actOnDoneWithSplits()
{
- LOGGER.info("CG: actOnDoneWithSplits()");
-
+ logPerhaps("actOnDoneWithSplits()");
board.clearRecruitedChits();
}
@@ -1294,8 +1271,7 @@
*/
private void postRecruitStuff(Legion legion)
{
- LOGGER.info("CG: postRecruitStuff(Legion legion)");
-
+ logPerhaps("postRecruitStuff(Legion legion)");
if (client.isMyLegion(legion))
{
pushUndoStack(legion.getMarkerId());
@@ -1331,8 +1307,7 @@
public void actOnRemoveCreaturePart2(Legion legion)
{
- LOGGER.info("CG: actOnRemoveCreaturePart2(Legion legion)");
-
+ logPerhaps("actOnRemoveCreaturePart2(Legion legion)");
if (!isReplayOngoing())
{
GUIMasterHex hex = board.getGUIHexByMasterHex(legion
@@ -1362,8 +1337,7 @@
public void actOnUndidSplit(Legion survivor, int turn)
{
- LOGGER.info("CG: actOnUndidSplit(Legion survivor, int turn)");
-
+ logPerhaps("actOnUndidSplit(Legion survivor, int turn)");
if (isReplayOngoing())
{
replayTurnChange(turn);
@@ -1413,8 +1387,7 @@
MasterHex currentHex, boolean teleport, CreatureType teleportingLord,
boolean splitLegionHasForcedMove)
{
- LOGGER.info("CG: actOnDidMove(Legion legion, MasterHex startingHex,");
-
+ logPerhaps("actOnDidMove(Legion legion, MasterHex startingHex,");
if (teleport)
{
eventViewer.newCreatureRevealEvent(RevealEvent.eventTeleport,
@@ -1450,8 +1423,7 @@
MasterHex currentHex, boolean splitLegionHasForcedMove,
boolean didTeleport)
{
- LOGGER.info("CG: actOnUndidMove(Legion legion, MasterHex formerHex,");
-
+ logPerhaps("actOnUndidMove(Legion legion, MasterHex formerHex,");
board.clearPossibleRecruitChits();
board.alignLegions(formerHex);
board.alignLegions(currentHex);
@@ -1483,16 +1455,14 @@
public void actOnNoMoreEngagements()
{
- LOGGER.info("CG: actOnNoMoreEngagements()");
-
+ logPerhaps("actOnNoMoreEngagements()");
board.setPhaseInfo("Press \"Done\" to end the engagements phase");
board.enableDoneAction();
}
public void alignLegionsMaybe(Legion legion)
{
- LOGGER.info("CG: alignLegionsMaybe(Legion legion)");
-
+ logPerhaps("alignLegionsMaybe(Legion legion)");
if (!isReplayOngoing())
{
board.alignLegions(legion.getCurrentHex());
@@ -1501,23 +1471,20 @@
public void actOnRemoveLegion(Legion legion)
{
- LOGGER.info("CG: actOnRemoveLegion(Legion legion)");
-
+ logPerhaps("actOnRemoveLegion(Legion legion)");
board.removeMarkerForLegion(legion);
}
public void actOnDoSummon()
{
- LOGGER.info("CG: actOnDoSummon()");
-
+ logPerhaps("actOnDoSummon()");
highlightEngagements();
board.repaint();
}
public void setLookAndFeel(String lfName)
{
- LOGGER.info("CG: setLookAndFeel(String lfName)");
-
+ logPerhaps("setLookAndFeel(String lfName)");
try
{
UIManager.setLookAndFeel(lfName);
@@ -1546,8 +1513,7 @@
public void updateEverything()
{
- LOGGER.info("CG: updateEverything()");
-
+ logPerhaps("updateEverything()");
board.updateComponentTreeUI();
board.pack();
@@ -1559,8 +1525,7 @@
private void updateTreeAndPack(Window window)
{
- LOGGER.info("CG: updateTreeAndPack(Window window)");
-
+ logPerhaps("updateTreeAndPack(Window window)");
if (window != null)
{
SwingUtilities.updateComponentTreeUI(window);
@@ -1570,8 +1535,7 @@
public void replayTurnChange(int nowTurn)
{
- LOGGER.info("CG: replayTurnChange(int nowTurn)");
-
+ logPerhaps("replayTurnChange(int nowTurn)");
assert board != null : "board is null in replayTurnChange!";
if (board != null)
@@ -1586,8 +1550,7 @@
public void actOnTellReplay(int maxTurn)
{
- LOGGER.info("CG: actOnTellReplay(int maxTurn)");
-
+ logPerhaps("actOnTellReplay(int maxTurn)");
if (isReplayOngoing())
{
// Switching to replay mode
@@ -1631,22 +1594,19 @@
public void makeBoardRecreateMarkers()
{
- LOGGER.info("CG: makeBoardRecreateMarkers()");
-
+ logPerhaps("makeBoardRecreateMarkers()");
board.recreateMarkers();
}
public void actOnTellRedoChange()
{
- LOGGER.info("CG: actOnTellRedoChange()");
-
+ logPerhaps("actOnTellRedoChange()");
// Nothing to do right now (was needed temporarily)
}
private void clearUndoStack()
{
- LOGGER.info("CG: clearUndoStack()");
-
+ logPerhaps("clearUndoStack()");
undoStack.clear();
}
@@ -1786,8 +1746,7 @@
public void repaintBattleBoard()
{
- LOGGER.info("CG: repaintBattleBoard()");
-
+ logPerhaps("repaintBattleBoard()");
if (battleBoard != null)
{
battleBoard.repaint();
@@ -1796,8 +1755,7 @@
public void repaintAllWindows()
{
- LOGGER.info("CG: repaintAllWindows()");
-
+ logPerhaps("repaintAllWindows()");
if (statusScreen != null)
{
statusScreen.repaint();
@@ -1815,8 +1773,7 @@
public void rescaleAllWindows()
{
- LOGGER.info("CG: rescaleAllWindows()");
-
+ logPerhaps("rescaleAllWindows()");
if (statusScreen != null)
{
statusScreen.rescale();
@@ -1854,8 +1811,7 @@
private void disposeMasterBoard()
{
- LOGGER.info("CG: disposeMasterBoard()");
-
+ logPerhaps("disposeMasterBoard()");
if (board != null)
{
board.dispose();
@@ -1869,8 +1825,7 @@
private void disposeBattleBoard()
{
- LOGGER.info("CG: disposeBattleBoard()");
-
+ logPerhaps("disposeBattleBoard()");
if (battleBoard != null)
{
battleBoard.dispose();
@@ -1883,8 +1838,7 @@
*/
public void disposePickCarryDialog()
{
- LOGGER.info("CG: disposePickCarryDialog()");
-
+ logPerhaps("disposePickCarryDialog()");
if (SwingUtilities.isEventDispatchThread())
{
actualDisposePickCarryDialog();
@@ -1911,8 +1865,7 @@
public void actualDisposePickCarryDialog()
{
- LOGGER.info("CG: actualDisposePickCarryDialog()");
-
+ logPerhaps("actualDisposePickCarryDialog()");
if (pickCarryDialog != null)
{
if (battleBoard != null)
@@ -1989,16 +1942,14 @@
public void showNegotiate(Legion attacker, Legion defender)
{
- LOGGER.info("CG: showNegotiate(Legion attacker, Legion defender)");
-
+ logPerhaps("showNegotiate(Legion attacker, Legion defender)");
board.clearDefenderFlee();
negotiate = new Negotiate(this, attacker, defender);
}
public void respawnNegotiate()
{
- LOGGER.info("CG: respawnNegotiate()");
-
+ logPerhaps("respawnNegotiate()");
if (negotiate != null)
{
negotiate.dispose();
@@ -2019,16 +1970,14 @@
public void showFlee(Client client, Legion ally, Legion enemy)
{
- LOGGER.info("CG: showFlee(Client client, Legion ally, Legion enemy)");
-
+ logPerhaps("showFlee(Client client, Legion ally, Legion enemy)");
Concede.flee(this, board.getFrame(), ally, enemy);
myTurnNotificationActions(ally);
}
private void myTurnNotificationActions(Legion ally)
{
- LOGGER.info("CG: myTurnNotificationActions(Legion ally)");
-
+ logPerhaps("myTurnNotificationActions(Legion ally)");
if (getGame().getDefender().equals(ally))
{
if (options.getOption(Options.turnStartBeep))
@@ -2044,8 +1993,7 @@
public void initShowEngagementResults()
{
- LOGGER.info("CG: initShowEngagementResults()");
-
+ logPerhaps("initShowEngagementResults()");
JFrame parent = getPreferredParent();
// no board at all, e.g. AI - nothing to do.
if (parent == null)
@@ -2087,8 +2035,7 @@
void highlightBattleSite(MasterHex battleSite)
{
- LOGGER.info("CG: highlightBattleSite(MasterHex battleSite)");
-
+ logPerhaps("highlightBattleSite(MasterHex battleSite)");
if (battleSite != null)
{
board.unselectAllHexes();
@@ -2133,29 +2080,25 @@
public void actOnEngagementCompleted()
{
- LOGGER.info("CG: actOnEngagementCompleted()");
-
+ logPerhaps("actOnEngagementCompleted()");
board.updateEngagementsLeftText();
}
public void setMulliganOldRoll(int movementRoll)
{
- LOGGER.info("CG: setMulliganOldRoll(int movementRoll)");
-
+ logPerhaps("setMulliganOldRoll(int movementRoll)");
eventViewer.setMulliganOldRoll(movementRoll);
}
public void tellWhatsHappening(String message)
{
- LOGGER.info("CG: tellWhatsHappening(String message)");
-
+ logPerhaps("tellWhatsHappening(String message)");
board.setPhaseInfo(message);
}
public void actOnTellMovementRoll(int roll)
{
- LOGGER.info("CG: actOnTellMovementRoll(int roll)");
-
+ logPerhaps("actOnTellMovementRoll(int roll)");
// TODO move if block to eventviewer itself?
// Not during replay, but during redo:
if (!isReplayOngoing() || isRedoOngoing())
@@ -2188,8 +2131,7 @@
public void revealEngagedCreatures(Legion legion,
final List<CreatureType> creatures, boolean isAttacker, String reason)
{
- LOGGER.info("CG: revealEngagedCreatures(Legion legion,");
-
+ logPerhaps("revealEngagedCreatures(Legion legion,");
// in engagement we need to update the remembered list, too.
if (isAttacker)
{
@@ -2334,8 +2276,7 @@
public void doPickSummonAngel(Legion legion,
List<Legion> possibleDonors)
{
- LOGGER.info("CG: doPickSummonAngel(Legion legion,");
-
+ logPerhaps("doPickSummonAngel(Legion legion,");
new SummonAngel(this, legion, possibleDonors);
}
@@ -2355,8 +2296,7 @@
private void markLegionAsSkipSplit(Legion legion)
{
- LOGGER.info("CG: markLegionAsSkipSplit(Legion legion)");
-
+ logPerhaps("markLegionAsSkipSplit(Legion legion)");
legion.setSkipThisTime(true);
pushUndoStack(legion.getMarkerId());
board.clearPossibleRecruitChits();
@@ -2365,8 +2305,7 @@
public void resetAllLegionFlags()
{
- LOGGER.info("CG: resetAllLegionFlags()");
-
+ logPerhaps("resetAllLegionFlags()");
for (Legion l : getOwningPlayer().getLegions())
{
l.setSkipThisTime(false);
@@ -2382,8 +2321,7 @@
public void doPickCarries(Client client, int carryDamage,
Set<String> carryTargetDescriptions)
{
- LOGGER.info("CG: doPickCarries(Client client, int carryDamage,");
-
+ logPerhaps("doPickCarries(Client client, int carryDamage,");
Set<BattleHex> carryTargetHexes = new HashSet<BattleHex>();
for (String desc : carryTargetDescriptions)
{
@@ -2402,8 +2340,7 @@
public void handlePickCarry(GUIBattleHex hex)
{
- LOGGER.info("CG: handlePickCarry(GUIBattleHex hex)");
-
+ logPerhaps("handlePickCarry(GUIBattleHex hex)");
String hexLabel = "";
if (hex != null)
{
@@ -2425,8 +2362,7 @@
public void doPickColor(final String playerName,
final List<PlayerColor> colorsLeft)
{
- LOGGER.info("CG: doPickColor(final String playerName,");
-
+ logPerhaps("doPickColor(final String playerName,");
if (SwingUtilities.isEventDispatchThread())
{
bringUpPickColorDialog(playerName, colorsLeft);
@@ -2558,8 +2494,7 @@
public void tellProposal(String proposalString)
{
- LOGGER.info("CG: tellProposal(String proposalString)");
-
+ logPerhaps("tellProposal(String proposalString)");
Proposal proposal = Proposal.makeFromString(proposalString, client
.getGameClientSide());
if (replyToProposal != null)
@@ -2573,8 +2508,7 @@
public void cleanupNegotiationDialogs()
{
- LOGGER.info("CG: cleanupNegotiationDialogs()");
-
+ logPerhaps("cleanupNegotiationDialogs()");
if (negotiate != null)
{
negotiate.dispose();
@@ -2590,8 +2524,7 @@
public void actOnTurnOrPlayerChange(Client client, int turnNr,
Player player)
{
- LOGGER.info("CG: actOnTurnOrPlayerChange(Client client, int turnNr,");
-
+ logPerhaps("actOnTurnOrPlayerChange(Client client, int turnNr,");
cleanupNegotiationDialogs();
if (isMyTurn())
{
@@ -2602,8 +2535,7 @@
public void actOnGameStarting()
{
- LOGGER.info("CG: actOnGameStarting()");
-
+ logPerhaps("actOnGameStarting()");
if (!client.isRemote())
{
board.enableSaveActions();
@@ -2612,8 +2544,7 @@
public void actOnSetupSplit()
{
- LOGGER.info("CG: actOnSetupSplit()");
-
+ logPerhaps("actOnSetupSplit()");
// TODO probably this can be removed?
if (isMyTurn())
{
@@ -2668,8 +2599,7 @@
private void validateLegions()
{
- LOGGER.info("CG: validateLegions()");
-
+ logPerhaps("validateLegions()");
boolean foundProblem = false;
for (Player p : client.getGameClientSide().getPlayers())
@@ -2697,8 +2627,7 @@
public void actOnSetupMuster()
{
- LOGGER.info("CG: actOnSetupMuster()");
-
+ logPerhaps("actOnSetupMuster()");
clearUndoStack();
cleanupNegotiationDialogs();
@@ -2713,8 +2642,7 @@
public void actOnSetupMove()
{
- LOGGER.info("CG: actOnSetupMove()");
-
+ logPerhaps("actOnSetupMove()");
clearUndoStack();
pendingMoves.clear();
pendingMoveHexes.clear();
@@ -2732,8 +2660,7 @@
public void actOnSetupFight()
{
- LOGGER.info("CG: actOnSetupFight()");
-
+ logPerhaps("actOnSetupFight()");
clearUndoStack();
board.setupFightMenu();
updateStatusScreen();
@@ -2741,8 +2668,7 @@
public void actOnSetupBattleFight()
{
- LOGGER.info("CG: actOnSetupBattleFight()");
-
+ logPerhaps("actOnSetupBattleFight()");
if (battleBoard != null)
{
battleBoard.updatePhaseAndTurn();
@@ -2762,8 +2688,7 @@
public void actOnSetupBattleMove()
{
- LOGGER.info("CG: actOnSetupBattleMove()");
-
+ logPerhaps("actOnSetupBattleMove()");
// needed/better to do here, than when finishing a battle turn,
// for two reasons: 1) done with moves quickly after a move (before
// server response received and handled) move would/might get into
@@ -2786,8 +2711,7 @@
public void actOnTellBattleMove(BattleHex startingHex,
BattleHex endingHex, boolean rememberForUndo)
{
- LOGGER.info("CG: actOnTellBattleMove(BattleHex startingHex,");
-
+ logPerhaps("actOnTellBattleMove(BattleHex startingHex,");
if (rememberForUndo)
{
pushUndoStack(endingHex.getLabel());
@@ -2804,22 +2728,19 @@
public void actOnPendingBattleMoveOver()
{
- LOGGER.info("CG: actOnPendingBattleMoveOver()");
-
+ logPerhaps("actOnPendingBattleMoveOver()");
battleBoard.actOnPendingBattleMoveOver();
}
public void actOnDoneWithBattleMoves()
{
- LOGGER.info("CG: actOnDoneWithBattleMoves()");
-
+ logPerhaps("actOnDoneWithBattleMoves()");
clearUndoStack();
}
public void actOnSetupBattleRecruit()
{
- LOGGER.info("CG: actOnSetupBattleRecruit()");
-
+ logPerhaps("actOnSetupBattleRecruit()");
if (battleBoard != null)
{
battleBoard.updatePhaseAndTurn();
@@ -2835,8 +2756,7 @@
public void actOnSetupBattleSummon()
{
- LOGGER.info("CG: actOnSetupBattleSummon()");
-
+ logPerhaps("actOnSetupBattleSummon()");
if (battleBoard != null)
{
battleBoard.updatePhaseAndTurn();
@@ -2856,8 +2776,7 @@
private void addBattleChit(GUIBattleChit battleChit)
{
- LOGGER.info("CG: addBattleChit(GUIBattleChit battleChit)");
-
+ logPerhaps("addBattleChit(GUIBattleChit battleChit)");
battleChits.add(battleChit);
}
@@ -2954,15 +2873,13 @@
public void actOnHitsSet(BattleUnit target)
{
- LOGGER.info("CG: actOnHitsSet(BattleUnit target)");
-
+ logPerhaps("actOnHitsSet(BattleUnit target)");
battleBoard.actOnHitsSet(target.getCurrentHex());
}
public void highlightCrittersWithTargets()
{
- LOGGER.info("CG: highlightCrittersWithTargets()");
-
+ logPerhaps("highlightCrittersWithTargets()");
if (battleBoard != null)
{
battleBoard.highlightCrittersWithTargets();
@@ -2971,8 +2888,7 @@
public void actOnApplyCarries(BattleHex hex)
{
- LOGGER.info("CG: actOnApplyCarries(BattleHex hex)");
-
+ logPerhaps("actOnApplyCarries(BattleHex hex)");
if (battleBoard != null)
{
battleBoard.unselectHex(hex);
@@ -2982,8 +2898,7 @@
public void actOnCleanupBattle()
{
- LOGGER.info("CG: actOnCleanupBattle()");
-
+ logPerhaps("actOnCleanupBattle()");
if (battleBoard != null)
{
battleBoard.dispose();
@@ -3013,8 +2928,7 @@
*/
public void undoRecruit(Legion legion)
{
- LOGGER.info("CG: undoRecruit(Legion legion)");
-
+ logPerhaps("undoRecruit(Legion legion)");
if (undoStack.contains(legion.getMarkerId()))
{
undoStack.remove(legion.getMarkerId());
@@ -3028,8 +2942,7 @@
*/
private void handleUndoRecruit(Legion legion)
{
- LOGGER.info("CG: handleUndoRecruit(Legion legion)");
-
+ logPerhaps("handleUndoRecruit(Legion legion)");
if (legion.hasRecruited())
{
waitCursor();
@@ -3074,8 +2987,7 @@
public void informSplitRequiredFirstRound()
{
- LOGGER.info("CG: informSplitRequiredFirstRound()");
-
+ logPerhaps("informSplitRequiredFirstRound()");
// must split in first turn - Done not allowed now
if (board != null && isMyTurn())
{
@@ -3109,8 +3021,7 @@
public void undoLastBattleMove()
{
- LOGGER.info("CG: undoLastBattleMove()");
-
+ logPerhaps("undoLastBattleMove()");
if (!isUndoStackEmpty())
{
String hexLabel = (String)popUndoStack();
@@ -3121,8 +3032,7 @@
public void undoAllBattleMoves()
{
- LOGGER.info("CG: undoAllBattleMoves()");
-
+ logPerhaps("undoAllBattleMoves()");
while (!isUndoStackEmpty())
{
undoLastBattleMove();
@@ -3131,8 +3041,7 @@
public void undoAllMoves()
{
- LOGGER.info("CG: undoAllMoves()");
-
+ logPerhaps("undoAllMoves()");
if (pendingMoves.size() > 0)
{
displayNoUndoWhilePendingMovesInfo();
@@ -3148,8 +3057,7 @@
public void undoAllRecruits()
{
- LOGGER.info("CG: undoAllRecruits()");
-
+ logPerhaps("undoAllRecruits()");
while (!isUndoStackEmpty())
{
undoLastRecruit();
@@ -3158,8 +3066,7 @@
private void displayNoUndoWhilePendingMovesInfo()
{
- LOGGER.info("CG: displayNoUndoWhilePendingMovesInfo()");
-
+ logPerhaps("displayNoUndoWhilePendingMovesInfo()");
JOptionPane.showMessageDialog(getMapOrBoardFrame(),
"For some moves is still the confirmation from server and "
+ "screen update missing!\n"
@@ -3170,22 +3077,19 @@
public void defaultCursor()
{
- LOGGER.info("CG: defaultCursor()");
-
+ logPerhaps("defaultCursor()");
board.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
public void waitCursor()
{
- LOGGER.info("CG: waitCursor()");
-
+ logPerhaps("waitCursor()");
board.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
public void doCleanupGUI()
{
- LOGGER.info("CG: doCleanupGUI()");
-
+ logPerhaps("doCleanupGUI()");
if (SwingUtilities.isEventDispatchThread())
{
cleanupGUI();
@@ -3213,8 +3117,7 @@
private void disposeMovementDie()
{
- LOGGER.info("CG: disposeMovementDie()");
-
+ logPerhaps("disposeMovementDie()");
movementDie = null;
}
@@ -3225,8 +3128,7 @@
private void cleanupGUI()
{
- LOGGER.info("CG: cleanupGUI()");
-
+ logPerhaps("cleanupGUI()");
try
{
disposeInspector();
@@ -3309,8 +3211,7 @@
public void showMessageDialogAndWait(String message)
{
- LOGGER.info("CG: showMessageDialogAndWait(String message)");
-
+ logPerhaps("showMessageDialogAndWait(String message)");
// Don't bother showing messages to AI players.
if (getOwningPlayer().isAI())
{
@@ -3347,8 +3248,7 @@
void doShowMessageDialog(String message)
{
- LOGGER.info("CG: doShowMessageDialog(String message)");
-
+ logPerhaps("doShowMessageDialog(String message)");
// For humans in autoplay do not show messages...
if (options.getOption(Options.autoPlay))
{
@@ -3475,8 +3375,7 @@
public void setMover(Legion legion)
{
- LOGGER.info("CG: setMover(Legion legion)");
-
+ logPerhaps("setMover(Legion legion)");
this.mover = legion;
}
@@ -3498,8 +3397,7 @@
public void actOnMoveNak()
{
- LOGGER.info("CG: actOnMoveNak()");
-
+ logPerhaps("actOnMoveNak()");
defaultCursor();
pendingMoves.clear();
pendingMoveHexes.clear();
@@ -3540,8 +3438,7 @@
public void setMovePending(Legion mover, MasterHex currentHex,
MasterHex targetHex)
{
- LOGGER.info("CG: setMovePending(Legion mover, MasterHex currentHex,");
-
+ logPerhaps("setMovePending(Legion mover, MasterHex currentHex,");
// board.visualizeMoveTarget(mover, currentHex, targetHex);
PendingMove move = new PendingMove(mover, currentHex, targetHex);
pendingMoves.add(move);
@@ -3558,8 +3455,7 @@
private void updatePendingText()
{
- LOGGER.info("CG: updatePendingText()");
-
+ logPerhaps("updatePendingText()");
int count = pendingMoves.size();
if (count > 0)
@@ -3593,8 +3489,7 @@
public void setMoveCompleted(Legion mover, MasterHex current,
MasterHex target)
{
- LOGGER.info("CG: setMoveCompleted(Legion mover, MasterHex current,");
-
+ logPerhaps("setMoveCompleted(Legion mover, MasterHex current,");
pendingMoveHexes.remove(target);
PendingMove foundMove = null;
for (PendingMove move : pendingMoves)
@@ -3638,8 +3533,7 @@
public void removeBattleChit(BattleUnit battleUnit)
{
- LOGGER.info("CG: removeBattleChit(BattleUnit battleUnit)");
-
+ logPerhaps("removeBattleChit(BattleUnit battleUnit)");
for (Iterator<GUIBattleChit> iterator = battleChits.iterator(); iterator
.hasNext();)
{
@@ -3658,22 +3552,19 @@
public void answerPickColor(PlayerColor color)
{
- LOGGER.info("CG: answerPickColor(PlayerColor color)");
-
+ logPerhaps("answerPickColor(PlayerColor color)");
getClient().answerPickColor(color);
}
public void leaveCarryMode()
{
- LOGGER.info("CG: leaveCarryMode()");
-
+ logPerhaps("leaveCarryMode()");
getClient().leaveCarryMode();
}
public void applyCarries(BattleHex hex)
{
- LOGGER.info("CG: applyCarries(BattleHex hex)");
-
+ logPerhaps("applyCarries(BattleHex hex)");
getClient().applyCarries(hex);
}
@@ -3687,57 +3578,49 @@
public void answerFlee(Legion ally, boolean answer)
{
- LOGGER.info("CG: answerFlee(Legion ally, boolean answer)");
-
+ logPerhaps("answerFlee(Legion ally, boolean answer)");
getClient().answerFlee(ally, answer);
}
public void answerConcede(Legion legion, boolean answer)
{
- LOGGER.info("CG: answerConcede(Legion legion, boolean answer)");
-
+ logPerhaps("answerConcede(Legion legion, boolean answer)");
getClient().answerConcede(legion, answer);
}
public void doBattleMove(int tag, BattleHex hex)
{
- LOGGER.info("CG: doBattleMove(int tag, BattleHex hex)");
-
+ logPerhaps("doBattleMove(int tag, BattleHex hex)");
getClient().doBattleMove(tag, hex);
}
public void undoBattleMove(BattleHex hex)
{
- LOGGER.info("CG: undoBattleMove(BattleHex hex)");
-
+ logPerhaps("undoBattleMove(BattleHex hex)");
getClient().undoBattleMove(hex);
}
public void strike(int tag, BattleHex hex)
{
- LOGGER.info("CG: strike(int tag, BattleHex hex)");
-
+ logPerhaps("strike(int tag, BattleHex hex)");
getClient().strike(tag, hex);
}
public void doneWithBattleMoves()
{
- LOGGER.info("CG: doneWithBattleMoves()");
-
+ logPerhaps("doneWithBattleMoves()");
getClient().doneWithBattleMoves();
}
public void doneWithStrikes()
{
- LOGGER.info("CG: doneWithStrikes()");
-
+ logPerhaps("doneWithStrikes()");
getClient().doneWithStrikes();
}
public void concede()
{
- LOGGER.info("CG: concede()");
-
+ logPerhaps("concede()");
getClient().concede();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-11-01 18:15:09
|
Revision: 5363
http://sourceforge.net/p/colossus/code/5363
Author: cleka
Date: 2013-11-01 18:15:06 +0000 (Fri, 01 Nov 2013)
Log Message:
-----------
Related to shutdown problems: do not requestConfirmCatchup when ping overdue; more logging.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java
trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java 2013-11-01 18:10:44 UTC (rev 5362)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java 2013-11-01 18:15:06 UTC (rev 5363)
@@ -82,6 +82,8 @@
private final ArrayList<String> recentlyProcessedLines = new ArrayList<String>(
MAX_KEEP_LINES);
+ private long lastPingReplyReceived = -1;
+
// Note that the client (SocketClientThread) sends ack every
// CLIENT_CTR_ACK_EVERY messages (currently 20)
// The two values above and the client value must fit together
@@ -155,6 +157,11 @@
return clientVersion >= IServer.CLIENT_VERSION_UNDERSTANDS_PING;
}
+ public long getMillisSincePingReply()
+ {
+ return lastPingReplyReceived - new Date().getTime();
+ }
+
protected boolean canHandleNewVariantXML()
{
return clientVersion >= IServer.CLIENT_VERSION_VARIANT_XML_OK;
@@ -1019,8 +1026,8 @@
else if (method.equals(Constants.replyToPing))
{
- LOGGER.fine("Client " + playerName
- + " replied to ping request - fine!");
+ lastPingReplyReceived = new Date().getTime();
+ server.replyToPing(playerName);
}
else if (method.equals(Constants.confirmCommitPoint))
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2013-11-01 18:10:44 UTC (rev 5362)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2013-11-01 18:15:06 UTC (rev 5363)
@@ -153,6 +153,8 @@
private final static int WEBGAMES_STARTUP_TIMEOUT_SECS = 20;
private final int PING_REQUEST_INTERVAL_SEC = 30;
+ private final long MAX_PING_OVERDUE = 50000;
+
/**
* How many ms ago last ping round was done.
*/
@@ -266,9 +268,8 @@
}
disposeRound++;
- LOGGER
- .info("In while !shutting down loop, initDisp true, round="
- + disposeRound);
+ LOGGER.info("In while !shutting down loop, "
+ + "initDisp true, round=" + disposeRound);
}
}
LOGGER.info("While !shuttingDown loop ends, disposeRound="
@@ -283,17 +284,17 @@
if (shuttingDown)
{
- LOGGER.info("shuttingDown set, before closeSocketAndSelector()");
+ LOGGER.fine("shuttingDown set, before closeSocketAndSelector()");
closeSocketAndSelector();
- LOGGER.info("shuttingDown set, after closeSocketAndSelector()");
+ LOGGER.fine("shuttingDown set, after closeSocketAndSelector()");
}
else
{
- LOGGER.info("shuttingDown NOT set");
+ LOGGER.fine("shuttingDown NOT set");
}
notifyThatGameFinished();
- LOGGER.info("Server.run() ends.");
+ LOGGER.fine("Server.run() ends.");
}
void initFileServer()
@@ -1895,6 +1896,11 @@
skip = true;
}
+ if (client.getMillisSincePingReply() > MAX_PING_OVERDUE)
+ {
+ skip = true;
+ }
+
if (!skip)
{
LOGGER.info("Adding to list for Catchup: "
@@ -3512,6 +3518,12 @@
}
}
+ void replyToPing(String playerName)
+ {
+ LOGGER.fine("Client " + playerName
+ + " replied to ping request - fine!");
+ }
+
/** Used to change a player name after color is assigned. */
void setPlayerName(Player player, String newName)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-11-01 18:10:46
|
Revision: 5362
http://sourceforge.net/p/colossus/code/5362
Author: cleka
Date: 2013-11-01 18:10:44 +0000 (Fri, 01 Nov 2013)
Log Message:
-----------
Protect GameServerSide.dispose() with a mutex.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java 2013-11-01 18:08:53 UTC (rev 5361)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java 2013-11-01 18:10:44 UTC (rev 5362)
@@ -2181,17 +2181,34 @@
}
+ private final Object disposeMutex = new Object();
+
+ private boolean disposeOngoing = false;
+
void dispose()
{
+ synchronized (disposeMutex)
+ {
+ if (disposeOngoing)
+ {
+ LOGGER.warning("Thread " + Thread.currentThread().getName()
+ + ": Trying to dispose game a 2nd time?");
+ return;
+ }
+ disposeOngoing = true;
+ }
+
+ LOGGER.info("GSS: Disposing game (thread "
+ + Thread.currentThread().getName() + ")");
if (server != null)
{
LOGGER.info("GSS: Stop Server running");
server.stopServerRunning();
}
-
if (notifyWebServer != null)
{
- LOGGER.info("GSS: notifyWebServer.serverStoppedRunning()");
+ LOGGER
+ .info("GSS: Notfifying Web Server that server stopped running.");
notifyWebServer.serverStoppedRunning();
notifyWebServer = null;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-11-01 18:08:57
|
Revision: 5361
http://sourceforge.net/p/colossus/code/5361
Author: cleka
Date: 2013-11-01 18:08:53 +0000 (Fri, 01 Nov 2013)
Log Message:
-----------
GSS.dispose(): NullCheck for notifyWebServer(), and log messages.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java 2013-10-31 15:31:46 UTC (rev 5360)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java 2013-11-01 18:08:53 UTC (rev 5361)
@@ -2185,10 +2185,16 @@
{
if (server != null)
{
+ LOGGER.info("GSS: Stop Server running");
server.stopServerRunning();
}
- notifyWebServer.serverStoppedRunning();
- notifyWebServer = null;
+
+ if (notifyWebServer != null)
+ {
+ LOGGER.info("GSS: notifyWebServer.serverStoppedRunning()");
+ notifyWebServer.serverStoppedRunning();
+ notifyWebServer = null;
+ }
}
private void placeInitialLegion(PlayerServerSide player, String markerId)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-10-31 15:31:49
|
Revision: 5360
http://sourceforge.net/p/colossus/code/5360
Author: cleka
Date: 2013-10-31 15:31:46 +0000 (Thu, 31 Oct 2013)
Log Message:
-----------
Removed catch for RTE because afterwards come catch for 'Exception' with almost same message. Improved the message reporting the exception.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java 2013-10-26 16:27:09 UTC (rev 5359)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/GameServerSide.java 2013-10-31 15:31:46 UTC (rev 5360)
@@ -1779,16 +1779,10 @@
return true;
}
- catch (RuntimeException rte)
- {
- LOGGER.log(Level.SEVERE, "RuntimeException!! "
- + "While trying to load (corrupt?) savegame", rte);
- dispose();
- return false;
- }
catch (Exception ex)
{
- LOGGER.log(Level.SEVERE, "Tried to load corrupt savegame", ex);
+ LOGGER.log(Level.SEVERE, ">>> Whoaah! Exception while "
+ + "tried to load savegame:", ex);
dispose();
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-10-26 16:27:12
|
Revision: 5359
http://sourceforge.net/p/colossus/code/5359
Author: cleka
Date: 2013-10-26 16:27:09 +0000 (Sat, 26 Oct 2013)
Log Message:
-----------
AddPossibleRecruitChits() was called from board through ClientGUI to board again.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClientGUI.java
trunk/Colossus/core/src/main/java/net/sf/colossus/client/NullClientGUI.java
trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java
trunk/Colossus/core/src/main/java/net/sf/colossus/gui/MasterBoard.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClientGUI.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClientGUI.java 2013-10-25 18:27:10 UTC (rev 5358)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/IClientGUI.java 2013-10-26 16:27:09 UTC (rev 5359)
@@ -72,9 +72,6 @@
public abstract int getNextSplitClickMode();
- public abstract void addPossibleRecruitChits(LegionClientSide legion,
- Set<MasterHex> hexes);
-
public abstract void eventViewerSetVisibleMaybe();
public abstract void autoInspectorSetDubiousAsBlanks(boolean newValue);
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/NullClientGUI.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/client/NullClientGUI.java 2013-10-25 18:27:10 UTC (rev 5358)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/NullClientGUI.java 2013-10-26 16:27:09 UTC (rev 5359)
@@ -294,13 +294,6 @@
}
- public void addPossibleRecruitChits(LegionClientSide legion,
- Set<MasterHex> hexes)
- {
- // TODO Auto-generated method stub
-
- }
-
public void alignLegionsMaybe(Legion legion)
{
// TODO Auto-generated method stub
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java 2013-10-25 18:27:10 UTC (rev 5358)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/gui/ClientGUI.java 2013-10-26 16:27:09 UTC (rev 5359)
@@ -913,20 +913,6 @@
return nextSplitClickMode;
}
- public void addPossibleRecruitChits(LegionClientSide legion,
- Set<MasterHex> hexes)
- {
- LOGGER.info("CG: addPossibleRecruitChits(LegionClientSide legion, "
- + "Set<MasterHex> hexes)");
-
- if (recruitChitMode == Options.showRecruitChitsNumNone)
- {
- return;
- }
-
- board.addPossibleRecruitChits(legion, hexes);
- }
-
/*
* Trigger side effects after changing an option value.
*
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/gui/MasterBoard.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/gui/MasterBoard.java 2013-10-25 18:27:10 UTC (rev 5358)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/gui/MasterBoard.java 2013-10-26 16:27:09 UTC (rev 5359)
@@ -1954,7 +1954,13 @@
combo.addAll(teleport);
combo.addAll(normal);
- gui.addPossibleRecruitChits(legion, combo);
+ LOGGER.info("MB: addPossibleRecruitChits(LegionClientSide legion, "
+ + "Set<MasterHex> hexes)");
+ if (gui.getRecruitChitMode() == Options.showRecruitChitsNumNone)
+ {
+ return;
+ }
+ addPossibleRecruitChits(legion, combo);
}
void highlightEngagements()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-10-25 18:27:14
|
Revision: 5358
http://sourceforge.net/p/colossus/code/5358
Author: cleka
Date: 2013-10-25 18:27:10 +0000 (Fri, 25 Oct 2013)
Log Message:
-----------
Corrections to that things were still written to channel after was setGone() already.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java
trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java 2013-10-25 18:18:39 UTC (rev 5357)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java 2013-10-25 18:27:10 UTC (rev 5358)
@@ -174,8 +174,8 @@
return;
}
+ sendViaChannel(Constants.dispose);
setIsGone("Server disposes client (all clients)");
- sendViaChannel(Constants.dispose);
server.queueClientHandlerForChannelChanges(this);
server.clientWontConfirmCatchup(this,
"Client disposed from server side.");
@@ -1124,7 +1124,7 @@
}
*/
- if (obsolete || socketChannel == null)
+ if (obsolete || socketChannel == null || isGone)
{
// do not send any more
if (cantSendMessageRepeated < 3)
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2013-10-25 18:18:39 UTC (rev 5357)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2013-10-25 18:27:10 UTC (rev 5358)
@@ -1400,8 +1400,8 @@
}
iClients.remove(existingCH);
realClients.remove(existingCH);
+ existingCH.declareObsolete();
queueClientHandlerForChannelChanges(existingCH);
- existingCH.declareObsolete();
LOGGER.info("Removing player with name " + name
+ " from forcedWithDrawlist. Size was "
+ forcedWithdraws.size());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-10-25 18:18:43
|
Revision: 5357
http://sourceforge.net/p/colossus/code/5357
Author: cleka
Date: 2013-10-25 18:18:39 +0000 (Fri, 25 Oct 2013)
Log Message:
-----------
Added null pointer check in SCT when receiving pingRequest too early (clientThread not up yet)
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2013-10-25 18:16:27 UTC (rev 5356)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/client/SocketClientThread.java 2013-10-25 18:18:39 UTC (rev 5357)
@@ -830,7 +830,8 @@
LOGGER.fine("SCT " + getName()
+ "received ping request from server");
replyToPing();
- if (clientThread.isEngagementStartupOngoing())
+ if (clientThread != null
+ && clientThread.isEngagementStartupOngoing())
{
int len = clientThread.getQueueLen();
logMsgToServer("I", "ClientThread queue length is " + len);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-10-25 18:16:34
|
Revision: 5356
http://sourceforge.net/p/colossus/code/5356
Author: cleka
Date: 2013-10-25 18:16:27 +0000 (Fri, 25 Oct 2013)
Log Message:
-----------
Store the last encoded message for possible later retrieval for logging
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java 2013-10-25 18:10:08 UTC (rev 5355)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandler.java 2013-10-25 18:16:27 UTC (rev 5356)
@@ -477,10 +477,13 @@
}
}
+ String lastEncodedMsg = "";
+
private void handleEncoding(String msg)
{
try
{
+ lastEncodedMsg = msg;
encodedMsg = msg;
String dataToSend = msg + "\n";
CharBuffer cb = CharBuffer.allocate(dataToSend.length());
@@ -554,6 +557,15 @@
private void attemptWritingToChannel()
{
+ if (isGone())
+ {
+ LOGGER.warning("isGone already true when attempting "
+ + "to do WriteToChannel " + lastEncodedMsg + " for player"
+ + getPlayerName());
+ LOGGER.warning("Reason: " + this.isGoneReason);
+ Thread.dumpStack();
+ return;
+ }
// Attempt to write away what is in buffer
try
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-10-25 18:10:12
|
Revision: 5355
http://sourceforge.net/p/colossus/code/5355
Author: cleka
Date: 2013-10-25 18:10:08 +0000 (Fri, 25 Oct 2013)
Log Message:
-----------
For isGone, store also the reason for later retrieval (especially for logging)
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java 2013-10-25 16:54:19 UTC (rev 5354)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/ClientHandlerStub.java 2013-10-25 18:10:08 UTC (rev 5355)
@@ -34,6 +34,7 @@
protected static int counter = 0;
protected boolean isGone = false;
+ protected String isGoneReason = "";
protected String playerName;
protected String signonName;
@@ -84,6 +85,7 @@
LOGGER.info("Setting isGone to true in CH for '" + getClientName()
+ "' (reason: " + reason + ")");
this.isGone = true;
+ this.isGoneReason = reason;
}
protected void sendToClient(String message)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cl...@us...> - 2013-10-25 16:54:21
|
Revision: 5354
http://sourceforge.net/p/colossus/code/5354
Author: cleka
Date: 2013-10-25 16:54:19 +0000 (Fri, 25 Oct 2013)
Log Message:
-----------
HandleChannelChanges now really removed iClient from list.
Earlier this could cause ConcurrentMod.Excp, but now that the game.dispose() is not exectured by EDT, instead by the selector thread, that does not happen any more.
Modified Paths:
--------------
trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
Modified: trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java
===================================================================
--- trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2013-10-25 16:52:19 UTC (rev 5353)
+++ trunk/Colossus/core/src/main/java/net/sf/colossus/server/Server.java 2013-10-25 16:54:19 UTC (rev 5354)
@@ -684,11 +684,11 @@
LOGGER.info("Handling channel changes, stub.");
}
- LOGGER.info("NOT REMOVING: CH " + nextCHS.getSignonName()
+ LOGGER.info("REALLY REMOVING: CH " + nextCHS.getSignonName()
+ " from clients list, list size is: " + iClients.size());
// For now removed, caused ConcurrentModificationException
// when game is closed via GUI
- // iClients.remove(nextCHS);
+ iClients.remove(nextCHS);
}
if (somethingToDo)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|