remove JBoss Remoting dependency + renamed Main to ServerMain

This commit is contained in:
betasteward 2015-06-18 14:58:17 -04:00
parent 8dab053d3b
commit 8d5ab2c9d1
13 changed files with 98 additions and 122 deletions

View file

@ -131,11 +131,6 @@
<artifactId>jlayer</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.mobicents.external.tritonus</groupId>
<artifactId>tritonus_share</artifactId>
<version>0.3.6</version>
</dependency>
</dependencies>
<!-- to get the reference to local repository with com\googlecode\jspf\jspf-core\0.9.1\ -->

View file

@ -25,21 +25,6 @@
<artifactId>jspf-core</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>org.jboss.remoting</groupId>
<artifactId>jboss-remoting</artifactId>
<version>2.5.4.SP5</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
<version>2.2.22.GA</version>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-serialization</artifactId>
<version>1.0.3.GA</version>
</dependency>
<dependency>
<groupId>concurrent</groupId>
<artifactId>concurrent</artifactId>

View file

@ -1,46 +1,46 @@
/*
* 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.interfaces;
import mage.interfaces.callback.CallbackClient;
import mage.utils.MageVersion;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public interface MageClient extends CallbackClient {
MageVersion getVersion();
void connected(String message);
void disconnected(boolean errorCall);
void showMessage(String message);
void showError(String message);
}
///*
//* 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.interfaces;
//
//import mage.interfaces.callback.CallbackClient;
//import mage.utils.MageVersion;
//
///**
// *
// * @author BetaSteward_at_googlemail.com
// */
//public interface MageClient extends CallbackClient {
//
// MageVersion getVersion();
// void connected(String message);
// void disconnected(boolean errorCall);
// void showMessage(String message);
// void showError(String message);
//
//}

View file

@ -28,6 +28,20 @@
<groupId>${project.groupId}</groupId>
<artifactId>mage-common</artifactId>
<version>${mage-version}</version>
<exclusions>
<exclusion>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.remoting</groupId>
<artifactId>jboss-remoting</artifactId>
</exclusion>
<exclusion>
<groupId>jboss</groupId>
<artifactId>jboss-serialization</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
@ -191,7 +205,7 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>mage.server.Main</mainClass>
<mainClass>mage.server.ServerMain</mainClass>
</manifest>
</archive>
</configuration>

View file

@ -159,7 +159,7 @@ public class ChatSession {
for (UUID userId: clients.keySet()) {
User chatUser = UserManager.getInstance().getUser(userId);
if (chatUser != null) {
Main.getInstance().sendChatMessage(chatUser.getSessionId(), chatId, new ChatMessage(userName, message, time, color, messageType, soundToPlay));
ServerMain.getInstance().sendChatMessage(chatUser.getSessionId(), chatId, new ChatMessage(userName, message, time, color, messageType, soundToPlay));
// user.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color, messageType, soundToPlay)));
}
else {

View file

@ -62,7 +62,7 @@ import mage.interfaces.ActionWithResult;
//import mage.interfaces.MageServer;
import org.mage.network.interfaces.MageServer;
import mage.interfaces.ServerState;
import mage.interfaces.callback.ClientCallback;
//import mage.interfaces.callback.ClientCallback;
import mage.remote.Connection;
import mage.remote.DisconnectReason;
import mage.remote.MageVersionException;
@ -116,7 +116,7 @@ import org.mage.network.model.MessageType;
*
* @author BetaSteward_at_googlemail.com, noxx
*/
public class Main implements MageServer {
public class ServerMain implements MageServer {
private static final Logger logger = Logger.getLogger(MageServer.class);
// private static final ExecutorService callExecutor = ThreadExecutor.getInstance().getCallExecutor();
@ -133,10 +133,10 @@ public class Main implements MageServer {
private final String password;
private final boolean testMode;
private static Main instance;
private static ServerMain instance;
private static Server server;
public Main(String password, boolean testMode) {
public ServerMain(String password, boolean testMode) {
this.password = password;
this.testMode = testMode;
ServerMessagesUtil.getInstance().getMessages();
@ -147,7 +147,7 @@ public class Main implements MageServer {
DeckValidatorFactory.getInstance().getDeckTypes().toArray(new String[DeckValidatorFactory.getInstance().getDeckTypes().size()]),
CubeFactory.getInstance().getDraftCubes().toArray(new String[CubeFactory.getInstance().getDraftCubes().size()]),
testMode,
Main.getVersion(),
ServerMain.getVersion(),
CardRepository.instance.getContentVersionConstant(),
ExpansionRepository.instance.getContentVersionConstant(),
GamesRoomManager.getInstance().getMainRoomId()
@ -210,7 +210,7 @@ public class Main implements MageServer {
logger.info("Config - save game active: " + (config.isSaveGameActivated() ? "True":"false"));
try {
instance = new Main(adminPassword, testMode);
instance = new ServerMain(adminPassword, testMode);
server = new Server(instance);
server.start(config.getPort(), config.isUseSSL());
} catch (Exception ex) {
@ -219,16 +219,16 @@ public class Main implements MageServer {
}
public static Main getInstance() {
public static ServerMain getInstance() {
return instance;
}
@Override
public boolean registerClient(Connection connection, String sessionId, MageVersion version, String host) {
if (version.compareTo(Main.getVersion()) != 0) {
if (version.compareTo(ServerMain.getVersion()) != 0) {
logger.info("MageVersionException: userName=" + connection.getUsername() + ", version=" + version);
LogServiceImpl.instance.log(LogKeys.KEY_WRONG_VERSION, connection.getUsername(), version.toString(), Main.getVersion().toString(), sessionId);
String message = "Wrong client version " + version + ", expecting version " + Main.getVersion() + ". \r\n\r\nPlease download needed version from http://XMage.de or http://www.slightlymagic.net/forum/viewforum.php?f=70";
LogServiceImpl.instance.log(LogKeys.KEY_WRONG_VERSION, connection.getUsername(), version.toString(), ServerMain.getVersion().toString(), sessionId);
String message = "Wrong client version " + version + ", expecting version " + ServerMain.getVersion() + ". \r\n\r\nPlease download needed version from http://XMage.de or http://www.slightlymagic.net/forum/viewforum.php?f=70";
server.informClient(sessionId, "Wrong version", message, MessageType.ERROR);
return false;
}

View file

@ -48,10 +48,6 @@ import mage.server.game.GamesRoomManager;
import mage.server.util.ConfigSettings;
import mage.view.UserDataView;
import org.apache.log4j.Logger;
import org.jboss.remoting.callback.AsynchInvokerCallbackHandler;
import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.HandleCallbackException;
import org.jboss.remoting.callback.InvokerCallbackHandler;
/**
*
@ -93,7 +89,7 @@ public class Session {
pingTaskExecutor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
Main.getInstance().pingClient(sessionId);
ServerMain.getInstance().pingClient(sessionId);
}
}, 10, 60, TimeUnit.SECONDS);
return registerUserHandling(connection);

View file

@ -37,7 +37,6 @@ import mage.server.services.LogKeys;
import mage.server.services.impl.LogServiceImpl;
import mage.view.UserDataView;
import org.apache.log4j.Logger;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.mage.network.Server;
import org.mage.network.model.MessageType;
@ -91,7 +90,7 @@ public class SessionManager {
return true;
}
logger.debug(connection.getUsername() + " not registered: " + returnMessage);
Main.getInstance().informClient(sessionId, "Connection Error", returnMessage, MessageType.ERROR);
ServerMain.getInstance().informClient(sessionId, "Connection Error", returnMessage, MessageType.ERROR);
// Server.informClient(sessionId, returnMessage, MessageType.ERROR);
// } else {

View file

@ -190,7 +190,7 @@ public class TableController {
user.showUserMessage("Join Table", "No valid deck selected!");
return false;
}
if (!Main.getInstance().isTestMode() && !table.getValidator().validate(deck)) {
if (!ServerMain.getInstance().isTestMode() && !table.getValidator().validate(deck)) {
StringBuilder sb = new StringBuilder("You (").append(name).append(") have an invalid deck for the selected ").append(table.getValidator().getName()).append(" Format. \n\n");
for (Map.Entry<String, String> entry : table.getValidator().getInvalid().entrySet()) {
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
@ -288,7 +288,7 @@ public class TableController {
return false;
}
if (!Main.getInstance().isTestMode() && !table.getValidator().validate(deck)) {
if (!ServerMain.getInstance().isTestMode() && !table.getValidator().validate(deck)) {
StringBuilder sb = new StringBuilder("You (").append(name).append(") have an invalid deck for the selected ").append(table.getValidator().getName()).append(" Format. \n\n");
for (Map.Entry<String, String> entry : table.getValidator().getInvalid().entrySet()) {
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
@ -377,7 +377,7 @@ public class TableController {
deck.setName(mPlayer.getDeck().getName());
}
}
if (!Main.getInstance().isTestMode() && !table.getValidator().validate(deck)) {
if (!ServerMain.getInstance().isTestMode() && !table.getValidator().validate(deck)) {
throw new InvalidDeckException("Invalid deck for this format", table.getValidator().getInvalid());
}
submitDeck(userId, playerId, deck);

View file

@ -198,60 +198,60 @@ public class User {
public void joinedTable(final UUID roomId, final UUID tableId, final UUID chatId, boolean owner, boolean tournament) {
// fireCallback(new ClientCallback("joinedTable", tableId, new TableClientMessage(roomId, tableId, isTournament)));
Main.getInstance().joinedTable(sessionId, roomId, tableId, chatId, owner, tournament);
ServerMain.getInstance().joinedTable(sessionId, roomId, tableId, chatId, owner, tournament);
}
public void gameStarted(final UUID gameId, final UUID playerId) {
// fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, playerId)));
Main.getInstance().gameStarted(sessionId, gameId, playerId);
ServerMain.getInstance().gameStarted(sessionId, gameId, playerId);
}
public void initGame(UUID gameId, GameView gameView) {
Main.getInstance().initGame(sessionId, gameId, gameView);
ServerMain.getInstance().initGame(sessionId, gameId, gameView);
}
public void gameAsk(UUID gameId, GameView gameView, String question) {
Main.getInstance().gameAsk(sessionId, gameId, gameView, question);
ServerMain.getInstance().gameAsk(sessionId, gameId, gameView, question);
}
public void gameTarget(UUID gameId, GameView gameView, String question, CardsView cardView, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
Main.getInstance().gameTarget(sessionId, gameId, gameView, question, cardView, targets, required, options);
ServerMain.getInstance().gameTarget(sessionId, gameId, gameView, question, cardView, targets, required, options);
}
public void gameSelect(UUID gameId, GameView gameView, String message, Map<String, Serializable> options) {
Main.getInstance().gameSelect(sessionId, gameId, gameView, message, options);
ServerMain.getInstance().gameSelect(sessionId, gameId, gameView, message, options);
}
public void gameChooseAbility(UUID gameId, AbilityPickerView abilities) {
Main.getInstance().gameChooseAbility(sessionId, gameId, abilities);
ServerMain.getInstance().gameChooseAbility(sessionId, gameId, abilities);
}
public void gameChoosePile(UUID gameId, String message, CardsView pile1, CardsView pile2) {
Main.getInstance().gameChoosePile(sessionId, gameId, message, pile1, pile2);
ServerMain.getInstance().gameChoosePile(sessionId, gameId, message, pile1, pile2);
}
public void gameChooseChoice(UUID gameId, Choice choice) {
Main.getInstance().gameChooseChoice(sessionId, gameId, choice);
ServerMain.getInstance().gameChooseChoice(sessionId, gameId, choice);
}
public void gamePlayMana(UUID gameId, GameView gameView, String message) {
Main.getInstance().gamePlayMana(sessionId, gameId, gameView, message);
ServerMain.getInstance().gamePlayMana(sessionId, gameId, gameView, message);
}
public void gamePlayXMana(UUID gameId, GameView gameView, String message) {
Main.getInstance().gamePlayXMana(sessionId, gameId, gameView, message);
ServerMain.getInstance().gamePlayXMana(sessionId, gameId, gameView, message);
}
public void gameSelectAmount(UUID gameId, String message, int min, int max) {
Main.getInstance().gameSelectAmount(sessionId, gameId, message, min, max);
ServerMain.getInstance().gameSelectAmount(sessionId, gameId, message, min, max);
}
public void endGameInfo(UUID gameId, GameEndView view) {
Main.getInstance().endGameInfo(sessionId, gameId, view);
ServerMain.getInstance().endGameInfo(sessionId, gameId, view);
}
public void userRequestDialog (UUID gameId, UserRequestMessage userRequestMessage) {
Main.getInstance().userRequestDialog(sessionId, gameId, userRequestMessage);
ServerMain.getInstance().userRequestDialog(sessionId, gameId, userRequestMessage);
}
public void ccDraftStarted(final UUID draftId, final UUID playerId) {
@ -284,7 +284,7 @@ public class User {
// messageData.add(titel);
// messageData.add(message);
// fireCallback(new ClientCallback("showUserMessage", null, messageData ));
Main.getInstance().informClient(sessionId, title, message, MessageType.INFORMATION);
ServerMain.getInstance().informClient(sessionId, title, message, MessageType.INFORMATION);
}
public boolean ccWatchGame(final UUID gameId) {

View file

@ -73,7 +73,7 @@ import mage.game.permanent.Permanent;
import mage.interfaces.Action;
import mage.players.Player;
import mage.server.ChatManager;
import mage.server.Main;
import mage.server.ServerMain;
import mage.server.Session;
import mage.server.SessionManager;
import mage.server.TableManager;
@ -935,7 +935,7 @@ public class GameController implements GameCallback {
private void error(String message, Exception ex) {
StringBuilder sb = new StringBuilder();
sb.append(message).append(ex.toString());
sb.append("\nServer version: ").append(Main.getVersion().toString());
sb.append("\nServer version: ").append(ServerMain.getVersion().toString());
sb.append("\n");
for (StackTraceElement e: ex.getStackTrace()) {
sb.append(e.toString()).append("\n");
@ -1058,14 +1058,13 @@ public class GameController implements GameCallback {
return;
}
cancelTimeout();
futureTimeout = timeoutIdleExecutor.schedule(
new Runnable() {
futureTimeout = timeoutIdleExecutor.schedule(new Runnable() {
@Override
public void run() {
idleTimeout(playerId);
}
},
Main.getInstance().isTestMode() ? 3600 :ConfigSettings.getInstance().getMaxSecondsIdle(),
ServerMain.getInstance().isTestMode() ? 3600 :ConfigSettings.getInstance().getMaxSecondsIdle(),
TimeUnit.SECONDS
);
}

View file

@ -38,7 +38,7 @@ import java.util.zip.GZIPInputStream;
import mage.game.Game;
import mage.game.GameState;
import mage.game.GameStates;
import mage.server.Main;
import mage.server.ServerMain;
import mage.util.CopierObjectInputStream;
import org.apache.log4j.Logger;
@ -87,7 +87,7 @@ public class GameReplay {
try{
InputStream file = new FileInputStream("saved/" + gameId.toString() + ".game");
InputStream buffer = new BufferedInputStream(file);
ObjectInput input = new CopierObjectInputStream(Main.classLoader, new GZIPInputStream(buffer));
ObjectInput input = new CopierObjectInputStream(ServerMain.classLoader, new GZIPInputStream(buffer));
try {
Game loadGame = (Game)input.readObject();
GameStates states = (GameStates)input.readObject();

12
pom.xml
View file

@ -65,18 +65,6 @@
</modules>
<repositories>
<repository>
<id>jboss-public-repository</id>
<name>JBoss Repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
<!-- These optional flags are designed to speed up your builds by reducing remote server calls -->
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<updatePolicy>daily</updatePolicy>
</snapshots>
</repository>
<repository>
<id>local-project-repo</id>
<url>file://${basedir}/repository</url>