Class ServerFacade


  • public abstract class ServerFacade
    extends Object
    Server facade is the main entry point to access all game session context independent functions of the game server. See also GameSession context object to access most managers and business objects.
    It can only be accessed when in the context of a game server thread.
    Example how to use the facade: ServerFacade.instance().getCurrentGameSession().getServerWorldManager().something();
    • Constructor Detail

      • ServerFacade

        protected ServerFacade()
        ServerFacade is a singleton, use .instance()
    • Method Detail

      • instance

        public static ServerFacade instance()
        ServerFacade is a singleton, use this method to access the facade
      • instance

        public static ServerFacade instance​(boolean checkContext)
        ServerFacade is a singleton, use this method to access the facade
        Parameters:
        checkContext - Checks whether called in server context. This makes sure it is not accidently called from the game client, which will have undefined effects. Only bypass this check if you know what you are doing.
      • isInServerContext

        public static boolean isInServerContext()
        Checks whether the current thread is running in context of the game server (i.e. is not part of the game client).
      • getVersionManager

        public abstract VersionManager getVersionManager()
        The version manager
      • getStorageManager

        public abstract StorageManager getStorageManager()
        The storage manager
      • getSecurityFacade

        public abstract SecurityFacade getSecurityFacade()
        The security facade
      • getObjectSerialization

        public abstract ObjectSerialization getObjectSerialization()
        The object de-/serializer
      • getMetaserverClient

        public abstract MetaserverClient getMetaserverClient()
        Api client for the metaserver
      • getBusinessObject

        public abstract <T> T getBusinessObject​(Class<? extends T> clazz)
        Business objects implementing various game mechanics. See .shared.bo package
      • getCurrentInstanceId

        public abstract UUID getCurrentInstanceId()
        Returns the game server instance id of the current thread context
      • getCurrentGameSession

        public abstract GameSession getCurrentGameSession()
        Returns the game session context object that is currently active in the thread context. Result may be null if there is no active game session context.
      • hasGameSessionById

        public abstract boolean hasGameSessionById​(UUID gameSessionId)
        Checks whether the given game session id is valid
      • getGameSessionById

        public abstract GameSession getGameSessionById​(UUID gameSessionId)
        Returns the game session by id
      • getGameSessionByPlayerId

        public abstract GameSession getGameSessionByPlayerId​(UUID netSessionId)
        Returns the game session a player is connected to
      • reportError

        public abstract void reportError​(String module,
                                         String message)
        Reports an error
      • publishMessage

        public abstract void publishMessage​(GameSession gameSession,
                                            Set<UUID> destinations,
                                            AbstractMessage message,
                                            boolean defer)
        Sends a Message to a client
        Parameters:
        destinations - A set of one or many player ids (same as net session ids)
        defer - Defer sending out this message. This is an optimization to send out multiple message in one datagram at the end of a turn to reduce overhead. It is right now only implemented for GameActionMessage, for other message types it has no effect.
      • publishMessageToAll

        public abstract void publishMessageToAll​(GameSession gameSession,
                                                 AbstractMessage message,
                                                 boolean defer)
        Sends a Message to all clients
        Parameters:
        defer - Defer sending out this message. This is an optimization to send out multiple message in one datagram at the end of a turn to reduce overhead. It is right now only implemented for GameActionMessage, for other message types it has no effect.
      • publishInternalMessage

        public abstract void publishInternalMessage​(GameSession gameSession,
                                                    AbstractMessage message,
                                                    boolean processImmediately)
        Sends a Message internally, it remains on the game server and can be processed by any module / composite / entity subscribing to it
        Parameters:
        processImmediately - Processes the message synchronously, otherwise it will be added to the regular message queue and processed in the next turn. Requires elevated security permissions, therefore it will throw an exception when used by scripts.
      • closeSession

        public abstract void closeSession​(UUID sessionId)
        Disconnects a certain player (same as net session)
      • createRandomGenerator

        public abstract Random createRandomGenerator​(long seed)
        Returns a new instance of a random number generator with a given seed
      • isDedicatedServer

        public abstract boolean isDedicatedServer()
        Checks whether the server that is running is dedicated
      • isOfficialServer

        public abstract boolean isOfficialServer()
        Checks whether the server that is running is an official server
      • getOfficialCheckpointSalt

        @RestrictedMethod
        public abstract byte[] getOfficialCheckpointSalt()