Some changes to userData handling. Added country flag to some dialogs. Saved and restored some more table columns width and order information.

This commit is contained in:
LevelX2 2015-06-28 00:10:38 +02:00
parent cb3b5f895b
commit 87f3978589
32 changed files with 1982 additions and 1699 deletions

View file

@ -1,31 +1,30 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.interfaces;
import java.util.List;
@ -40,14 +39,14 @@ import mage.constants.PlayerAction;
import mage.game.GameException;
import mage.game.match.MatchOptions;
import mage.game.tournament.TournamentOptions;
import mage.players.net.UserData;
import mage.utils.MageVersion;
import mage.view.DraftPickView;
import mage.view.GameView;
import mage.view.MatchView;
import mage.view.RoomUsersView;
import mage.view.TableView;
import mage.view.TournamentView;
import mage.view.UserDataView;
import mage.view.RoomUsersView;
import mage.view.UserView;
/**
@ -58,22 +57,28 @@ public interface MageServer {
// connection methods
boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException;
boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException;
// Not used
// void deregisterClient(String sessionId) throws MageException;
// update methods
List<ExpansionInfo> getMissingExpansionData(List<String> codes);
List<CardInfo> getMissingCardsData(List<String> classNames);
// user methods
boolean setUserData(String userName, String sessionId, UserDataView userDataView) throws MageException;
boolean setUserData(String userName, String sessionId, UserData userData) throws MageException;
void sendFeedbackMessage(String sessionId, String username, String title, String type, String message, String email) throws MageException;
// server state methods
ServerState getServerState() throws MageException;
List<RoomUsersView> getRoomUsers(UUID roomId) throws MageException;
List<MatchView> getFinishedMatches(UUID roomId) throws MageException;
Object getServerMessagesCompressed(String sessionId) throws MageException; // messages of the day
// ping - extends session
@ -81,27 +86,46 @@ public interface MageServer {
//table methods
TableView createTable(String sessionId, UUID roomId, MatchOptions matchOptions) throws MageException;
TableView createTournamentTable(String sessionId, UUID roomId, TournamentOptions tournamentOptions) throws MageException;
boolean joinTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
boolean joinTournamentTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
boolean submitDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
void updateDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
boolean watchTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
boolean watchTournamentTable(String sessionId, UUID tableId) throws MageException;
boolean leaveTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
void swapSeats(String sessionId, UUID roomId, UUID tableId, int seatNum1, int seatNum2) throws MageException;
void removeTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException;
TableView getTable(UUID roomId, UUID tableId) throws MageException;
List<TableView> getTables(UUID roomId) throws MageException;
//chat methods
void sendChatMessage(UUID chatId, String userName, String message) throws MageException;
void joinChat(UUID chatId, String sessionId, String userName) throws MageException;
void leaveChat(UUID chatId, String sessionId) throws MageException;
UUID getTableChatId(UUID tableId) throws MageException;
UUID getGameChatId(UUID gameId) throws MageException;
UUID getRoomChatId(UUID roomId) throws MageException;
UUID getTournamentChatId(UUID tournamentId) throws MageException;
//room methods
@ -109,50 +133,77 @@ public interface MageServer {
//game methods
boolean startMatch(String sessionId, UUID roomId, UUID tableId) throws MageException;
void joinGame(UUID gameId, String sessionId) throws MageException;
void watchGame(UUID gameId, String sessionId) throws MageException;
void stopWatching(UUID gameId, String sessionId) throws MageException;
void sendPlayerUUID(UUID gameId, String sessionId, UUID data) throws MageException;
void sendPlayerString(UUID gameId, String sessionId, String data) throws MageException;
void sendPlayerBoolean(UUID gameId, String sessionId, Boolean data) throws MageException;
void sendPlayerInteger(UUID gameId, String sessionId, Integer data) throws MageException;
void sendPlayerManaType(UUID gameId, UUID playerId, String sessionId, ManaType data) throws MageException;
void quitMatch(UUID gameId, String sessionId) throws MageException;
GameView getGameView(UUID gameId, String sessionId, UUID playerId) throws MageException;
// priority, undo, concede, mana pool
void sendPlayerAction(PlayerAction playerAction, UUID gameId, String sessionId, Object data) throws MageException;
//tournament methods
boolean startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
void joinTournament(UUID draftId, String sessionId) throws MageException;
void quitTournament(UUID tournamentId, String sessionId) throws MageException;
TournamentView getTournament(UUID tournamentId) throws MageException;
//draft methods
void joinDraft(UUID draftId, String sessionId) throws MageException;
void quitDraft(UUID draftId, String sessionId) throws MageException;
DraftPickView sendCardPick(UUID draftId, String sessionId, UUID cardId, Set<UUID> hiddenCards) throws MageException;
void sendCardMark(UUID draftId, String sessionId, UUID cardId) throws MageException;
//challenge methods
// void startChallenge(String sessionId, UUID roomId, UUID tableId, UUID challengeId) throws MageException;
//replay methods
void replayGame(UUID gameId, String sessionId) throws MageException;
void startReplay(UUID gameId, String sessionId) throws MageException;
void stopReplay(UUID gameId, String sessionId) throws MageException;
void nextPlay(UUID gameId, String sessionId) throws MageException;
void previousPlay(UUID gameId, String sessionId) throws MageException;
void skipForward(UUID gameId, String sessionId, int moves) throws MageException;
//test methods
void cheat(UUID gameId, String sessionId, UUID playerId, DeckCardLists deckList) throws MageException;
boolean cheat(UUID gameId, String sessionId, UUID playerId, String cardName) throws MageException;
//admin methods
List<UserView> getUsers(String sessionId) throws MageException;
void disconnectUser(String sessionId, String userSessionId) throws MageException;
void endUserSession(String sessionId, String userSessionId) throws MageException;
void removeTable(String sessionId, UUID tableId) throws MageException;
void sendBroadcastMessage(String sessionId, String message) throws MageException;
}

View file

@ -1,31 +1,30 @@
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.remote;
import java.net.Inet4Address;
@ -34,8 +33,7 @@ import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import mage.players.net.UserSkipPrioritySteps;
import mage.view.UserDataView;
import mage.players.net.UserData;
/**
*
@ -55,37 +53,36 @@ public class Connection {
private int clientCardDatabaseVersion;
private boolean forceDBComparison;
private UserDataView userData;
private UserData userData;
// private int avatarId;
// private boolean showAbilityPickerForced;
// private boolean allowRequestShowHandCards;
// private boolean confirmEmptyManaPool;
// private String flagName;
// private UserSkipPrioritySteps userSkipPrioritySteps;
private static final String serialization = "?serializationtype=jboss";
private static final String serialization = "?serializationtype=jboss";
private static final String transport = "bisocket";
private final String parameter;
private final String parameter;
public Connection() {
this("");
}
public Connection(String parameter) {
this.parameter = parameter;
}
@Override
public int hashCode() {
return (transport + host + Integer.toString(port) + proxyType.toString()).hashCode();
return (transport + host + Integer.toString(port) + proxyType.toString()).hashCode();
}
@Override
public boolean equals(Object object) {
if (! (object instanceof Connection)) {
return false;
if (!(object instanceof Connection)) {
return false;
}
Connection otherConnection = (Connection) object;
return hashCode() == otherConnection.hashCode();
@ -119,6 +116,7 @@ public class Connection {
}
public enum ProxyType {
SOCKS("Socks"), HTTP("HTTP"), NONE("None");
private final String text;
@ -207,12 +205,12 @@ public class Connection {
}
public static InetAddress getLocalAddress() throws SocketException {
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements(); ) {
NetworkInterface iface = interfaces.nextElement( );
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements();) {
NetworkInterface iface = interfaces.nextElement();
if (iface.isLoopback()) {
continue;
}
for (InterfaceAddress addr: iface.getInterfaceAddresses()) {
for (InterfaceAddress addr : iface.getInterfaceAddresses()) {
if (addr != null) {
InetAddress iaddr = addr.getAddress();
if (iaddr != null && iaddr instanceof Inet4Address) {
@ -224,11 +222,11 @@ public class Connection {
return null;
}
public void setUserData(UserDataView userData) {
this.userData= userData;
public void setUserData(UserData userData) {
this.userData = userData;
}
public UserDataView getUserData() {
public UserData getUserData() {
return userData;
}

View file

@ -1,31 +1,30 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.remote;
import java.io.IOException;
@ -61,8 +60,8 @@ import mage.interfaces.MageClient;
import mage.interfaces.MageServer;
import mage.interfaces.ServerState;
import mage.interfaces.callback.ClientCallback;
import mage.players.net.UserData;
import mage.utils.CompressUtil;
import mage.players.net.UserSkipPrioritySteps;
import mage.view.DraftPickView;
import mage.view.GameTypeView;
import mage.view.MatchView;
@ -70,7 +69,6 @@ import mage.view.RoomUsersView;
import mage.view.TableView;
import mage.view.TournamentTypeView;
import mage.view.TournamentView;
import mage.view.UserDataView;
import mage.view.UserView;
import org.apache.log4j.Logger;
import org.jboss.remoting.CannotConnectException;
@ -106,7 +104,7 @@ public class SessionImpl implements Session {
private Connection connection;
private final static int PING_CYCLES = 10;
private final LinkedList<Long> pingTime = new LinkedList<>();
private String pingInfo = "";
private String pingInfo = "";
private static boolean debugMode = false;
private boolean canceled = false;
@ -123,7 +121,7 @@ public class SessionImpl implements Session {
public String getSessionId() {
return sessionId;
}
@Override
public synchronized boolean connect(Connection connection) {
if (isConnected()) {
@ -165,82 +163,88 @@ public class SessionImpl implements Session {
break;
}
InvokerLocator clientLocator = new InvokerLocator(connection.getURI());
Map<String, String> metadata = new HashMap<>();
/*
5.8.3.1.1. Write timeouts
The socket timeout facility offered by the JDK applies only to read operations on the socket. As of release 2.5.2,
the socket and bisocket (and also sslsocket and sslbisocket) transports offer a write timeout facility. When a client
or server is configured, in any of the usual ways, with the parameter org.jboss.remoting.transport.socket.SocketWrapper.WRITE_TIMEOUT
(actual value "writeTimeout") set to a positive value (in milliseconds), all write operations will time out if they do
not complete within the configured period. When a write operation times out, the socket upon which the write was invoked
will be closed, which is likely to result in a java.net.SocketException.
Note. A SocketException is considered to be a "retriable" exception, so, if the parameter "numberOfCallRetries" is set
to a value greater than 1, an invocation interrupted by a write timeout can be retried.
Note. The write timeout facility applies to writing of both invocations and responses. It applies to push callbacks as well.
*/
5.8.3.1.1. Write timeouts
The socket timeout facility offered by the JDK applies only to read operations on the socket. As of release 2.5.2,
the socket and bisocket (and also sslsocket and sslbisocket) transports offer a write timeout facility. When a client
or server is configured, in any of the usual ways, with the parameter org.jboss.remoting.transport.socket.SocketWrapper.WRITE_TIMEOUT
(actual value "writeTimeout") set to a positive value (in milliseconds), all write operations will time out if they do
not complete within the configured period. When a write operation times out, the socket upon which the write was invoked
will be closed, which is likely to result in a java.net.SocketException.
Note. A SocketException is considered to be a "retriable" exception, so, if the parameter "numberOfCallRetries" is set
to a value greater than 1, an invocation interrupted by a write timeout can be retried.
Note. The write timeout facility applies to writing of both invocations and responses. It applies to push callbacks as well.
*/
metadata.put(SocketWrapper.WRITE_TIMEOUT, "2000");
metadata.put("generalizeSocketException", "true");
server = (MageServer) TransporterClient.createTransporterClient(clientLocator.getLocatorURI(), MageServer.class, metadata);
// http://docs.jboss.org/jbossremoting/docs/guide/2.5/html_single/#d0e1057
Map<String, String> clientMetadata = new HashMap<>();
clientMetadata.put(SocketWrapper.WRITE_TIMEOUT, "2000");
/* generalizeSocketException
* If set to false, a failed invocation will be retried in the case of
* SocketExceptions. If set to true, a failed invocation will be retried in the case of
* <classname>SocketException</classname>s and also any <classname>IOException</classname>
* whose message matches the regular expression
* <code>^.*(?:connection.*reset|connection.*closed|broken.*pipe).*$</code>.
* See also the "numberOfCallRetries" parameter, above. The default value is false.*/
/* generalizeSocketException
* If set to false, a failed invocation will be retried in the case of
* SocketExceptions. If set to true, a failed invocation will be retried in the case of
* <classname>SocketException</classname>s and also any <classname>IOException</classname>
* whose message matches the regular expression
* <code>^.*(?:connection.*reset|connection.*closed|broken.*pipe).*$</code>.
* See also the "numberOfCallRetries" parameter, above. The default value is false.*/
clientMetadata.put("generalizeSocketException", "true");
/* A remoting server also has the capability to detect when a client is no longer available.
* This is done by estabilishing a lease with the remoting clients that connect to a server.
* On the client side, an org.jboss.remoting.LeasePinger periodically sends PING messages to
* the server, and on the server side an org.jboss.remoting.Lease informs registered listeners
* if the PING doesn't arrive withing the specified timeout period. */
/* A remoting server also has the capability to detect when a client is no longer available.
* This is done by estabilishing a lease with the remoting clients that connect to a server.
* On the client side, an org.jboss.remoting.LeasePinger periodically sends PING messages to
* the server, and on the server side an org.jboss.remoting.Lease informs registered listeners
* if the PING doesn't arrive withing the specified timeout period. */
clientMetadata.put(Client.ENABLE_LEASE, "true");
/*
When the socket client invoker makes its first invocation, it will check to see if there is an available
socket connection in its pool. Since is the first invocation, there will not be and will create a new socket
connection and use it for making the invocation. Then when finished making invocation, will return the still
active socket connection to the pool. As more client invocations are made, is possible for the number of
socket connections to reach the maximum allowed (which is controlled by 'clientMaxPoolSize' property). At this
point, when the next client invocation is made, it will wait up to some configured number of milliseconds, at
which point it will throw an org.jboss.remoting.CannotConnectException. The number of milliseconds is given by
the parameter MicroSocketClientInvoker.CONNECTION_WAIT (actual value "connectionWait"), with a default of
30000 milliseconds. Note that if more than one call retry is configured (see next paragraph),
the CannotConnectException will be swallowed.
Once the socket client invoker get an available socket connection from the pool, are not out of the woods yet.
For example, a network problem could cause a java.net.SocketException. There is also a possibility that the socket
connection, while still appearing to be valid, has "gone stale" while sitting in the pool. For example, a ServerThread
on the other side of the connection could time out and close its socket. If the attempt to complete an invocation
fails, then MicroSocketClientInvoker will make a number of attempts, according to the parameter "numberOfCallRetries",
with a default value of 3. Once the configured number of retries has been exhausted,
an org.jboss.remoting.InvocationFailureException will be thrown.
*/
When the socket client invoker makes its first invocation, it will check to see if there is an available
socket connection in its pool. Since is the first invocation, there will not be and will create a new socket
connection and use it for making the invocation. Then when finished making invocation, will return the still
active socket connection to the pool. As more client invocations are made, is possible for the number of
socket connections to reach the maximum allowed (which is controlled by 'clientMaxPoolSize' property). At this
point, when the next client invocation is made, it will wait up to some configured number of milliseconds, at
which point it will throw an org.jboss.remoting.CannotConnectException. The number of milliseconds is given by
the parameter MicroSocketClientInvoker.CONNECTION_WAIT (actual value "connectionWait"), with a default of
30000 milliseconds. Note that if more than one call retry is configured (see next paragraph),
the CannotConnectException will be swallowed.
Once the socket client invoker get an available socket connection from the pool, are not out of the woods yet.
For example, a network problem could cause a java.net.SocketException. There is also a possibility that the socket
connection, while still appearing to be valid, has "gone stale" while sitting in the pool. For example, a ServerThread
on the other side of the connection could time out and close its socket. If the attempt to complete an invocation
fails, then MicroSocketClientInvoker will make a number of attempts, according to the parameter "numberOfCallRetries",
with a default value of 3. Once the configured number of retries has been exhausted,
an org.jboss.remoting.InvocationFailureException will be thrown.
*/
clientMetadata.put("numberOfCallRetries", "1");
/**
* I'll explain the meaning of "secondaryBindPort" and "secondaryConnectPort", and maybe that will help.
* The Remoting bisocket transport creates two ServerSockets on the server. The "primary" ServerSocket is used to create
* connections used for ordinary invocations, e.g., a request to create a JMS consumer, and the "secondary" ServerSocket
* is used to create "control" connections for internal Remoting messages. The port for the primary ServerSocket is configured
* by the "serverBindPort" parameter, and the port for the secondary ServerSocket is, by default, chosen randomly.
* The "secondaryBindPort" parameter can be used to assign a specific port to the secondary ServerSocket. Now, if there is a
* translating firewall between the client and server, the client should be given the value of the port that is translated
* to the actual binding port of the secondary ServerSocket.
* For example, your configuration will tell the secondary ServerSocket to bind to port 14000, and it will tell the client to
* connect to port 14001. It assumes that there is a firewall which will translate 14001 to 14000. Apparently, that's not happening.
* I'll explain the meaning of "secondaryBindPort" and
* "secondaryConnectPort", and maybe that will help. The Remoting
* bisocket transport creates two ServerSockets on the server. The
* "primary" ServerSocket is used to create connections used for
* ordinary invocations, e.g., a request to create a JMS consumer,
* and the "secondary" ServerSocket is used to create "control"
* connections for internal Remoting messages. The port for the
* primary ServerSocket is configured by the "serverBindPort"
* parameter, and the port for the secondary ServerSocket is, by
* default, chosen randomly. The "secondaryBindPort" parameter can
* be used to assign a specific port to the secondary ServerSocket.
* Now, if there is a translating firewall between the client and
* server, the client should be given the value of the port that is
* translated to the actual binding port of the secondary
* ServerSocket. For example, your configuration will tell the
* secondary ServerSocket to bind to port 14000, and it will tell
* the client to connect to port 14001. It assumes that there is a
* firewall which will translate 14001 to 14000. Apparently, that's
* not happening.
*/
// secondaryBindPort - the port to which the secondary server socket is to be bound. By default, an arbitrary port is selected.
// secondaryConnectPort - the port clients are to use to connect to the secondary server socket.
// By default, the value of secondaryBindPort is used. secondaryConnectPort is useful if the server is behind a translating firewall.
// By default, the value of secondaryBindPort is used. secondaryConnectPort is useful if the server is behind a translating firewall.
// Indicated the max number of threads used within oneway thread pool.
clientMetadata.put(Client.MAX_NUM_ONEWAY_THREADS, "10");
clientMetadata.put(Remoting.USE_CLIENT_CONNECTION_IDENTITY, "true");
@ -269,7 +273,7 @@ public class SessionImpl implements Session {
logger.warn("There should be one callback Connector (number existing = " + callbackConnectors.size() + ")");
}
logger.info("Trying to connect as " + (this.getUserName() == null ? "":this.getUserName()) + " to XMAGE server at " + connection.getHost() + ":" + connection.getPort());
logger.info("Trying to connect as " + (this.getUserName() == null ? "" : this.getUserName()) + " to XMAGE server at " + connection.getHost() + ":" + connection.getPort());
callbackClient.invoke(null);
this.sessionId = callbackClient.getSessionId();
@ -289,15 +293,15 @@ public class SessionImpl implements Session {
if (!connection.getUsername().equals("Admin")) {
updateDatabase(connection.isForceDBComparison(), serverState);
}
logger.info("Connected as " + (this.getUserName() == null ? "":this.getUserName()) + " to MAGE server at " + connection.getHost() + ":" + connection.getPort());
client.connected(this.getUserName() == null ? "":this.getUserName() +"@" + connection.getHost() + ":" + connection.getPort() +" ");
logger.info("Connected as " + (this.getUserName() == null ? "" : this.getUserName()) + " to MAGE server at " + connection.getHost() + ":" + connection.getPort());
client.connected(this.getUserName() == null ? "" : this.getUserName() + "@" + connection.getHost() + ":" + connection.getPort() + " ");
return true;
}
disconnect(false);
// client.showMessage("Unable to connect to server.");
} catch (MalformedURLException ex) {
logger.fatal("", ex);
client.showMessage("Unable to connect to server. " + ex.getMessage());
client.showMessage("Unable to connect to server. " + ex.getMessage());
} catch (UndeclaredThrowableException ex) {
String addMessage = "";
if (ex.getCause() instanceof InvocationFailureException) {
@ -311,17 +315,17 @@ public class SessionImpl implements Session {
if (addMessage.isEmpty()) {
logger.fatal("", ex);
}
client.showMessage("Unable to connect to server. " + addMessage + (ex.getMessage() != null ? ex.getMessage():""));
client.showMessage("Unable to connect to server. " + addMessage + (ex.getMessage() != null ? ex.getMessage() : ""));
} catch (IOException ex) {
logger.fatal("", ex);
String addMessage = "";
if (ex.getMessage() != null && ex.getMessage().startsWith("Unable to perform invocation")) {
addMessage = "Maybe the server version is not compatible. ";
}
client.showMessage("Unable to connect to server. " + addMessage + ex.getMessage() != null ? ex.getMessage():"");
client.showMessage("Unable to connect to server. " + addMessage + ex.getMessage() != null ? ex.getMessage() : "");
} catch (MageVersionException ex) {
if (!canceled) {
client.showMessage("Unable to connect to server. " + ex.getMessage());
client.showMessage("Unable to connect to server. " + ex.getMessage());
}
disconnect(false);
} catch (CannotConnectException ex) {
@ -334,12 +338,12 @@ public class SessionImpl implements Session {
disconnect(false);
StringBuilder sb = new StringBuilder();
sb.append("Unable to connect to server.\n");
for (StackTraceElement element :t.getStackTrace()) {
for (StackTraceElement element : t.getStackTrace()) {
sb.append(element.toString()).append("\n");
}
client.showMessage(sb.toString());
}
}
}
return false;
}
@ -350,8 +354,8 @@ public class SessionImpl implements Session {
List<CardInfo> cards = server.getMissingCardsData(classNames);
CardRepository.instance.addCards(cards);
CardRepository.instance.setContentVersion(serverState.getCardsContentVersion());
logger.info("Updating client cards DB - existing cards: " + classNames.size() + " new cards: " + cards.size() +
" content versions - server: " + serverState.getCardsContentVersion() + " client: " + cardDBVersion);
logger.info("Updating client cards DB - existing cards: " + classNames.size() + " new cards: " + cards.size()
+ " content versions - server: " + serverState.getCardsContentVersion() + " client: " + cardDBVersion);
}
long expansionDBVersion = ExpansionRepository.instance.getContentVersionFromDB();
@ -362,8 +366,8 @@ public class SessionImpl implements Session {
ExpansionRepository.instance.add(expansion);
}
ExpansionRepository.instance.setContentVersion(serverState.getExpansionsContentVersion());
logger.info("Updating client expansions DB - existing sets: " + setCodes.size() + " new sets: " + expansions.size()+
" content versions - server: " + serverState.getExpansionsContentVersion() + " client: " + expansionDBVersion);
logger.info("Updating client expansions DB - existing sets: " + setCodes.size() + " new sets: " + expansions.size()
+ " content versions - server: " + serverState.getExpansionsContentVersion() + " client: " + expansionDBVersion);
}
}
@ -399,7 +403,8 @@ public class SessionImpl implements Session {
/**
*
* @param askForReconnect - true = connection was lost because of error and ask the user if he want to try to reconnect
* @param askForReconnect - true = connection was lost because of error and
* ask the user if he want to try to reconnect
*/
@Override
public synchronized void disconnect(boolean askForReconnect) {
@ -410,7 +415,7 @@ public class SessionImpl implements Session {
if (connection == null || sessionState == SessionState.DISCONNECTED) {
return;
}
try {
callbackClient.removeListener(callbackHandler);
callbackClient.disconnect();
@ -450,10 +455,11 @@ public class SessionImpl implements Session {
}
class CallbackHandler implements InvokerCallbackHandler {
@Override
public void handleCallback(Callback callback) throws HandleCallbackException {
//logger.info("callback handler");
client.processCallback((ClientCallback)callback.getCallbackObject());
client.processCallback((ClientCallback) callback.getCallbackObject());
}
}
@ -502,7 +508,6 @@ public class SessionImpl implements Session {
return serverState.getDraftCubes();
}
@Override
public List<TournamentTypeView> getTournamentTypes() {
return serverState.getTournamentTypes();
@ -561,7 +566,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return null;
}
@ -588,7 +593,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -621,7 +626,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -637,7 +642,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -652,7 +657,7 @@ public class SessionImpl implements Session {
handleMageException(ex);
throw new MageRemoteException();
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return null;
}
@ -667,7 +672,7 @@ public class SessionImpl implements Session {
handleMageException(ex);
throw new MageRemoteException();
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return null;
}
@ -697,7 +702,7 @@ public class SessionImpl implements Session {
handleMageException(ex);
throw new MageRemoteException();
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return null;
}
@ -711,7 +716,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return null;
}
@ -726,7 +731,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -741,7 +746,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -756,7 +761,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -771,7 +776,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -800,7 +805,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return null;
}
@ -829,7 +834,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -845,7 +850,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
// } finally {
// lock.readLock().unlock();
}
@ -863,7 +868,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
// } finally {
// lock.readLock().unlock();
}
@ -895,7 +900,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -910,7 +915,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -925,7 +930,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -940,7 +945,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -955,7 +960,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -969,7 +974,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return null;
}
@ -983,7 +988,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return null;
}
@ -997,7 +1002,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1013,13 +1018,14 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
/**
* Remove table - called from admin console
*
* @param tableId
* @return
*/
@ -1033,7 +1039,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1048,7 +1054,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1062,7 +1068,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1088,7 +1094,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1107,7 +1113,6 @@ public class SessionImpl implements Session {
// }
// return false;
// }
@Override
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
try {
@ -1119,7 +1124,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1136,7 +1141,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1198,7 +1203,7 @@ public class SessionImpl implements Session {
}
return false;
}
@Override
public boolean stopWatching(UUID gameId) {
try {
@ -1209,7 +1214,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1224,7 +1229,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1239,7 +1244,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1254,7 +1259,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1269,7 +1274,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1284,7 +1289,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1299,7 +1304,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1313,7 +1318,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return null;
}
@ -1342,7 +1347,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
handleThrowable(t);
}
return false;
}
@ -1384,14 +1389,13 @@ public class SessionImpl implements Session {
client.showError(ex.getMessage());
}
@Override
public String getUserName() {
return connection.getUsername();
}
@Override
public boolean updatePreferencesForServer(UserDataView userData) {
public boolean updatePreferencesForServer(UserData userData) {
try {
if (isConnected()) {
server.setUserData(connection.getUsername(), sessionId, userData);
@ -1411,26 +1415,26 @@ public class SessionImpl implements Session {
if (isConnected()) {
long startTime = System.nanoTime();
if (!server.ping(sessionId, pingInfo)) {
logger.error("Ping failed: " + this.getUserName() + " Session: " + sessionId + " to MAGE server at " + connection.getHost() +":" + connection.getPort());
logger.error("Ping failed: " + this.getUserName() + " Session: " + sessionId + " to MAGE server at " + connection.getHost() + ":" + connection.getPort());
throw new MageException("Ping failed");
}
pingTime.add(System.nanoTime() - startTime);
long milliSeconds = TimeUnit.MILLISECONDS.convert(pingTime.getLast(), TimeUnit.NANOSECONDS);
String lastPing = milliSeconds > 0 ? milliSeconds+"ms" : "<1ms";
String lastPing = milliSeconds > 0 ? milliSeconds + "ms" : "<1ms";
if (pingTime.size() > PING_CYCLES) {
pingTime.poll();
}
long sum = 0;
for (Long time :pingTime) {
for (Long time : pingTime) {
sum += time;
}
milliSeconds = TimeUnit.MILLISECONDS.convert(sum / pingTime.size(), TimeUnit.NANOSECONDS);
pingInfo = lastPing + " (Av: " + (milliSeconds > 0 ? milliSeconds + "ms":"<1ms")+")";
pingInfo = lastPing + " (Av: " + (milliSeconds > 0 ? milliSeconds + "ms" : "<1ms") + ")";
}
return true;
} catch (MageException ex) {
handleMageException(ex);
disconnect(true);
handleMageException(ex);
disconnect(true);
} catch (Throwable t) {
handleThrowable(t);
}
@ -1448,7 +1452,6 @@ public class SessionImpl implements Session {
}
class MageAuthenticator extends Authenticator {
private final String username;
@ -1460,7 +1463,7 @@ class MageAuthenticator extends Authenticator {
}
@Override
public PasswordAuthentication getPasswordAuthentication () {
return new PasswordAuthentication (username, password.toCharArray());
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password.toCharArray());
}
}

View file

@ -1,33 +1,33 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.remote.interfaces;
import mage.view.UserDataView;
import mage.players.net.UserData;
/**
* @author noxx
@ -36,5 +36,5 @@ public interface ClientData {
String getUserName();
boolean updatePreferencesForServer(UserDataView userData);
boolean updatePreferencesForServer(UserData userData);
}

View file

@ -1,31 +1,30 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
@ -44,12 +43,14 @@ import mage.game.command.Commander;
import mage.game.command.Emblem;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.players.net.UserData;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class PlayerView implements Serializable {
private static final long serialVersionUID = 1L;
private final UUID playerId;
@ -67,7 +68,7 @@ public class PlayerView implements Serializable {
private final CardsView exile = new CardsView();
private final Map<UUID, PermanentView> battlefield = new LinkedHashMap<>();
private final CardView topCard;
private final UserDataView userDataView;
private final UserData userData;
private final List<CommandObjectView> commandList = new ArrayList<>();
private final List<UUID> attachments = new ArrayList<>();
private final int statesSavedSize;
@ -89,50 +90,49 @@ public class PlayerView implements Serializable {
this.isActive = (player.getId().equals(state.getActivePlayerId()));
this.hasPriority = player.getId().equals(state.getPriorityPlayerId());
this.priorityTimeLeft = player.getPriorityTimeLeft();
this.timerActive = (this.hasPriority && player.isGameUnderControl()) ||
(player.getPlayersUnderYourControl().contains(state.getPriorityPlayerId())) ||
player.getId().equals(game.getState().getChoosingPlayerId());
this.timerActive = (this.hasPriority && player.isGameUnderControl())
|| (player.getPlayersUnderYourControl().contains(state.getPriorityPlayerId()))
|| player.getId().equals(game.getState().getChoosingPlayerId());
this.hasLeft = player.hasLeft();
for (Card card: player.getGraveyard().getCards(game)) {
for (Card card : player.getGraveyard().getCards(game)) {
graveyard.put(card.getId(), new CardView(card, game, false));
}
for (ExileZone exileZone : game.getExile().getExileZones()) {
for (Card card : exileZone.getCards(game)) {
if (player.getId().equals(card.getOwnerId())) {
exile.put(card.getId(), new CardView(card, game, false)); // unnown if it's allowed to look under a face down card
}
}
}
}
for (Permanent permanent: state.getBattlefield().getAllPermanents()) {
for (Permanent permanent : state.getBattlefield().getAllPermanents()) {
if (showInBattlefield(permanent, state)) {
PermanentView view = new PermanentView(permanent, game.getCard(permanent.getId()), createdForPlayerId, game);
battlefield.put(view.getId(), view);
}
}
this.topCard = player.isTopCardRevealed() && player.getLibrary().size() > 0 ?
new CardView(player.getLibrary().getFromTop(game)) : null;
this.topCard = player.isTopCardRevealed() && player.getLibrary().size() > 0
? new CardView(player.getLibrary().getFromTop(game)) : null;
if (player.getUserData() != null) {
this.userDataView = new UserDataView(player.getUserData());
this.userData = player.getUserData();
} else {
this.userDataView = UserDataView.getDefaultUserDataView();
this.userData = UserData.getDefaultUserDataView();
}
for (CommandObject commandObject : game.getState().getCommand()) {
if (commandObject instanceof Emblem) {
Emblem emblem = (Emblem) commandObject;
if (emblem.getControllerId().equals(this.playerId)) {
Card sourceCard = game.getCard(((CommandObject)emblem).getSourceId());
Card sourceCard = game.getCard(((CommandObject) emblem).getSourceId());
if (sourceCard != null) {
commandList.add(new EmblemView(emblem, sourceCard));
}
}
}
else if(commandObject instanceof Commander){
Commander commander = (Commander)commandObject;
if(commander.getControllerId().equals(this.playerId)){
} else if (commandObject instanceof Commander) {
Commander commander = (Commander) commandObject;
if (commander.getControllerId().equals(this.playerId)) {
Card sourceCard = game.getCard(commander.getSourceId());
if(sourceCard != null){
if (sourceCard != null) {
commandList.add(new CommanderView(commander, sourceCard, game));
}
}
@ -157,13 +157,11 @@ public class PlayerView implements Serializable {
//show permanents controlled by player or attachments to permanents controlled by player
if (permanent.getAttachedTo() == null) {
return permanent.getControllerId().equals(playerId);
}
else {
} else {
Permanent attachedTo = state.getPermanent(permanent.getAttachedTo());
if (attachedTo != null) {
return attachedTo.getControllerId().equals(playerId);
}
else {
} else {
return permanent.getControllerId().equals(playerId);
}
}
@ -221,8 +219,8 @@ public class PlayerView implements Serializable {
return this.topCard;
}
public UserDataView getUserData() {
return this.userDataView;
public UserData getUserData() {
return this.userData;
}
public List<CommandObjectView> getCommadObjectList() {

View file

@ -1,31 +1,30 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
@ -37,16 +36,23 @@ import mage.game.Seat;
* @author BetaSteward_at_googlemail.com
*/
public class SeatView implements Serializable {
private static final long serialVersionUID = 1L;
private final String flagName;
private UUID playerId;
private String playerName;
private String playerType;
private final String playerName;
private final String playerType;
public SeatView(Seat seat) {
if (seat.getPlayer() != null) {
this.playerId = seat.getPlayer().getId();
this.playerName = seat.getPlayer().getName();
this.flagName = seat.getPlayer().getUserData().getFlagName();
} else {
// Empty seat
this.playerName = "";
this.flagName = "";
}
this.playerType = seat.getPlayerType();
}
@ -63,4 +69,8 @@ public class SeatView implements Serializable {
return playerType;
}
public String getFlagName() {
return flagName;
}
}

View file

@ -1,16 +1,16 @@
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,12 +20,11 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
@ -35,9 +34,11 @@ import mage.game.tournament.TournamentPlayer;
*
* @author BetaSteward_at_googlemail.com
*/
public class TournamentPlayerView implements Serializable, Comparable{
public class TournamentPlayerView implements Serializable, Comparable {
private static final long serialVersionUID = 1L;
private final String flagName;
private final String name;
private final String state;
private final String results;
@ -46,7 +47,7 @@ public class TournamentPlayerView implements Serializable, Comparable{
TournamentPlayerView(TournamentPlayer tournamentPlayer) {
this.name = tournamentPlayer.getPlayer().getName();
StringBuilder sb = new StringBuilder(tournamentPlayer.getState().toString());
StringBuilder sb = new StringBuilder(tournamentPlayer.getState().toString());
String stateInfo = tournamentPlayer.getStateInfo();
if (!stateInfo.isEmpty()) {
sb.append(" (").append(stateInfo).append(")");
@ -56,6 +57,7 @@ public class TournamentPlayerView implements Serializable, Comparable{
this.points = tournamentPlayer.getPoints();
this.results = tournamentPlayer.getResults();
this.quit = !tournamentPlayer.isInTournament();
this.flagName = tournamentPlayer.getPlayer().getUserData().getFlagName();
}
public String getName() {
@ -83,4 +85,7 @@ public class TournamentPlayerView implements Serializable, Comparable{
return ((TournamentPlayerView) t).getPoints() - this.getPoints();
}
public String getFlagName() {
return flagName;
}
}

View file

@ -2,6 +2,7 @@ package mage.view;
import java.io.Serializable;
import mage.players.net.UserData;
import mage.players.net.UserGroup;
import mage.players.net.UserSkipPrioritySteps;
/**
@ -20,11 +21,11 @@ public class UserDataView implements Serializable {
String flagName;
protected boolean askMoveToGraveOrder;
static UserDataView getDefaultUserDataView() {
return new UserDataView(0, false, false, true, null,"world.png", false);
static UserData getDefaultUserDataView() {
return new UserData(UserGroup.DEFAULT, 0, false, false, true, null, "world.png", false);
}
public UserDataView(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards,
public UserDataView(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards,
boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps, String flagName, boolean askMoveToGraveOrder) {
this.avatarId = avatarId;
this.showAbilityPickerForced = showAbilityPickerForced;
@ -33,7 +34,7 @@ public class UserDataView implements Serializable {
this.confirmEmptyManaPool = confirmEmptyManaPool;
this.flagName = flagName;
this.askMoveToGraveOrder = askMoveToGraveOrder;
}
public UserDataView(UserData userData) {
@ -74,5 +75,5 @@ public class UserDataView implements Serializable {
public boolean askMoveToGraveOrder() {
return askMoveToGraveOrder;
}
}