Package org.vrspace.server.core
Class WorldManager
- java.lang.Object
-
- org.vrspace.server.core.WorldManager
-
@Component("world") @DependsOn("database") public class WorldManager extends ObjectMain component that manages all interactions with virtual worlds.- Author:
- joe
-
-
Field Summary
Fields Modifier and Type Field Description protected ConcurrentHashMap<ID,Entity>cacheprotected ClientFactoryclientFactoryprotected ServerConfigconfigprotected com.fasterxml.jackson.databind.ObjectMapperjacksonprotected ScenePropertiesscenePropertiesprotected SessionTrackersessionTracker
-
Constructor Summary
Constructors Constructor Description WorldManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<VRObject>add(Client client, List<VRObject> objects)Add objects to client's current positionWorlddefaultWorld()voiddispatch(VREvent event)Welcomeenter(Client client, String worldName)Welcomeenter(Client client, World world)List<Entity>find(Predicate<? super Entity> filter)Find some objects, in-memory operation on cache.protected VRObjectget(ID id)ClientgetClientByName(String name)<T extends Client>
TgetClientByName(String name, Class<T> cls)WorldgetOrCreateWorld(String name)Set<VRObject>getPermanents(Client client)Set<VRObject>getRange(Client client, Point from, Point to)WorldgetWorld(String name)voidinit()List<Class<?>>listClasses()Welcomelogin(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session)Remote user login over websocket.Welcomelogin(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session, Class<? extends Client> clientClass)Common login procedure for both users and remote servers.voidlogin(Client client)Stage 2 of login, executed once client has been identified.voidlogout(Client client)voidremove(Client client, VRObject obj)<T extends VRObject>
Tsave(T obj)WelcomeserverLogin(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session)Login for remote serversvoidstartSession(Client client)
-
-
-
Field Detail
-
config
@Autowired protected ServerConfig config
-
sceneProperties
@Autowired protected SceneProperties sceneProperties
-
jackson
@Autowired protected com.fasterxml.jackson.databind.ObjectMapper jackson
-
clientFactory
@Autowired protected ClientFactory clientFactory
-
sessionTracker
protected SessionTracker sessionTracker
-
cache
protected ConcurrentHashMap<ID,Entity> cache
-
-
Method Detail
-
init
@PostConstruct public void init()
-
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:
-
save
public <T extends VRObject> T save(T obj)
-
add
public List<VRObject> add(Client client, List<VRObject> objects)
Add objects to client's current position- Parameters:
client- client adding objectsobjects- objects to add- Returns:
- list of added objects
-
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
-
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 sessionclientClass- either User or RemoteServerclientFactory- either userFactory or serverFactory- Returns:
- See Also:
login(ConcurrentWebSocketSessionDecorator)
-
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()
-
startSession
public void startSession(Client client) throws SessionException
- Throws:
SessionException
-
logout
@Transactional public void logout(Client client)
-
-