Search in sources :

Example 1 with HandleCallbackException

use of org.jboss.remoting.callback.HandleCallbackException in project mage by magefree.

the class RandomString method fireCallback.

public void fireCallback(final ClientCallback call) {
    boolean lockSet = false;
    try {
        if (valid && callBackLock.tryLock(50, TimeUnit.MILLISECONDS)) {
            call.setMessageId(messageId.incrementAndGet());
            lockSet = true;
            Callback callback = new Callback(call);
            callbackHandler.handleCallbackOneway(callback);
        }
    } catch (InterruptedException ex) {
        logger.warn("SESSION LOCK - fireCallback - userId: " + userId + " messageId: " + call.getMessageId(), ex);
    } catch (HandleCallbackException ex) {
        this.valid = false;
        managerFactory.userManager().getUser(userId).ifPresent(user -> {
            user.setUserState(User.UserState.Disconnected);
            logger.warn("SESSION CALLBACK EXCEPTION - " + user.getName() + " userId " + userId + " messageId: " + call.getMessageId() + " - cause: " + getBasicCause(ex).toString());
            logger.trace("Stack trace:", ex);
            managerFactory.sessionManager().disconnect(sessionId, LostConnection);
        });
    } catch (Exception ex) {
        logger.warn("Unspecific exception:", ex);
    } finally {
        if (lockSet) {
            callBackLock.unlock();
        }
    }
}
Also used : Callback(org.jboss.remoting.callback.Callback) java.util(java.util) UserData(mage.players.net.UserData) ReentrantLock(java.util.concurrent.locks.ReentrantLock) AsynchInvokerCallbackHandler(org.jboss.remoting.callback.AsynchInvokerCallbackHandler) MageException(mage.MageException) TimeUnit(java.util.concurrent.TimeUnit) UserGroup(mage.players.net.UserGroup) Logger(org.apache.log4j.Logger) GamesRoom(mage.server.game.GamesRoom) ConfigSettings(mage.server.managers.ConfigSettings) ManagerFactory(mage.server.managers.ManagerFactory) Matcher(java.util.regex.Matcher) ClientCallbackMethod(mage.interfaces.callback.ClientCallbackMethod) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LostConnection(mage.server.DisconnectReason.LostConnection) SystemUtil(mage.server.util.SystemUtil) Constants(mage.constants.Constants) Pattern(java.util.regex.Pattern) RandomUtil(mage.util.RandomUtil) HandleCallbackException(org.jboss.remoting.callback.HandleCallbackException) InvokerCallbackHandler(org.jboss.remoting.callback.InvokerCallbackHandler) ClientCallback(mage.interfaces.callback.ClientCallback) Callback(org.jboss.remoting.callback.Callback) ClientCallback(mage.interfaces.callback.ClientCallback) HandleCallbackException(org.jboss.remoting.callback.HandleCallbackException) MageException(mage.MageException) HandleCallbackException(org.jboss.remoting.callback.HandleCallbackException)

Aggregations

java.util (java.util)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 MageException (mage.MageException)1 Constants (mage.constants.Constants)1 ClientCallback (mage.interfaces.callback.ClientCallback)1 ClientCallbackMethod (mage.interfaces.callback.ClientCallbackMethod)1 UserData (mage.players.net.UserData)1 UserGroup (mage.players.net.UserGroup)1 LostConnection (mage.server.DisconnectReason.LostConnection)1 GamesRoom (mage.server.game.GamesRoom)1 ConfigSettings (mage.server.managers.ConfigSettings)1 ManagerFactory (mage.server.managers.ManagerFactory)1 SystemUtil (mage.server.util.SystemUtil)1 RandomUtil (mage.util.RandomUtil)1 Logger (org.apache.log4j.Logger)1 AsynchInvokerCallbackHandler (org.jboss.remoting.callback.AsynchInvokerCallbackHandler)1