Class WorldManager

java.lang.Object
org.vrspace.server.core.WorldManager

@Component("world") @DependsOn("database") public class WorldManager extends Object
Main component that manages all interactions with virtual worlds.
Author:
joe
  • Field Details

  • Constructor Details

    • WorldManager

      public WorldManager()
  • Method Details

    • init

      @PostConstruct public void init()
    • get

      public VRObject get(ID id)
      Get a cached VRObject
      Parameters:
      id -
      Returns:
    • get

      public <T extends VRObject> T get(Class<T> cls, Long id)
    • find

      public List<Entity> find(Predicate<? super Entity> filter)
      Find some objects, in-memory operation on cache.
      Parameters:
      filter - Predicate to select objects, e.g. o->o.isActive()
      Returns:
    • listClasses

      public List<Class<?>> listClasses()
    • getWorld

      public World getWorld(String name)
    • saveWorld

      public World saveWorld(World world)
    • getOrCreateWorld

      public World getOrCreateWorld(String name)
    • getClient

      public Client getClient(Long id)
    • getClientByName

      public Client getClientByName(String name)
    • getClientByName

      public <T extends Client> T getClientByName(String name, Class<T> cls)
    • save

      public <T extends VRObject> T save(T obj)
    • getRange

      public Set<VRObject> getRange(Client client, Point from, Point to)
    • getPermanents

      public Set<VRObject> getPermanents(Client client)
    • add

      public VRObject add(Client client, VRObject o)
      Add an object to client's current position
      Parameters:
      client - Client adding objects
      o - A VRObject
      Returns:
      saved VRObject
    • isOwner

      public boolean isOwner(Client client, VRObject o)
    • add

      public List<VRObject> add(Client client, List<VRObject> objects)
      Add objects to client's current position
      Parameters:
      client - client adding objects
      objects - objects to add
      Returns:
      list of added objects
    • remove

      public void remove(Client client, VRObject obj)
    • login

      @Transactional public Welcome login(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session)
      Remote user login over websocket. Called from SessionManager, after websocket session has been established. Uses session security context (principal) to identify user and fetch/create the appropriate Client object from the ClientFactory. May create a new guest client, if guest (anonymous) connections are allowed.
      Parameters:
      session - websocket session
      Returns:
      Welcome message
    • serverLogin

      @Transactional public Welcome serverLogin(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session)
      Login for remote servers
      See Also:
    • login

      @Transactional public Welcome login(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session, Class<? extends Client> clientClass)
      Common login procedure for both users and remote servers. This may change, same for the time being.
      Parameters:
      session - web socket session
      clientClass - either User or RemoteServer
      clientFactory - either userFactory or serverFactory
      Returns:
      See Also:
    • login

      public void login(Client client)
      Stage 2 of login, executed once client has been identified. Does not depend on websocket session, can be used for internal login, e.g. bots.
      Parameters:
      client -
    • defaultWorld

      public World defaultWorld()
    • enter

      public Welcome enter(Client client, String worldName)
    • enter

      public Welcome enter(Client client, World world)
    • startSession

      public void startSession(Client client) throws SessionException
      Throws:
      SessionException
    • logout

      @Transactional public void logout(Client client)
    • dispatch

      @Transactional public void dispatch(VREvent event) throws Exception
      Throws:
      Exception
    • getStreamManager

      public StreamManager getStreamManager()
      CHECKME Commands need access to StreamManager
      Returns:
      StreamManager