Package org.vrspace.server.core
Class WorldManager
java.lang.Object
org.vrspace.server.core.WorldManager
Main component that manages all interactions with virtual worlds.
- Author:
- joe
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConcurrentHashMap<ID, Entity> protected ClientFactoryprotected ServerConfigprotected Dispatcherprotected com.fasterxml.jackson.databind.ObjectMapperprotected com.fasterxml.jackson.databind.ObjectMapperprotected ScenePropertiesprotected SessionTrackerprotected WorldConfig -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd objects to client's current positionAdd an object to client's current positionprotected voiddeleteWorld(World world) voidFind some objects, in-memory operation on cache.<T extends VRObject>
TGet a cached VRObjectIf the client is currently active, cached version of the client, otherwise nullgetClientByName(String name) <T extends Client>
TgetClientByName(String name, Class<T> cls) getDb()CHECKME Commands need access to databasegetOrCreateWorld(String name) getPermanents(Client client) CHECKME Commands need access to StreamManagervoidinit()booleanlogin(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session) Remote user login over websocket.login(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session, Class<? extends Client> clientClass) Common login procedure for both users and remote servers.voidStage 2 of login, executed once client has been identified.voidCalled by SessionManager after the client closes the web socketvoid<T extends VRObject>
Tsave(T obj) serverLogin(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session) Login for remote serversintstartSession(Client client) The client has set own properties, entered a world, and going online.
-
Field Details
-
config
-
worldConfig
-
sceneProperties
-
jackson
@Autowired @Qualifier("objectMapper") protected com.fasterxml.jackson.databind.ObjectMapper jackson -
privateJackson
@Autowired @Qualifier("privateMapper") protected com.fasterxml.jackson.databind.ObjectMapper privateJackson -
clientFactory
-
dispatcher
-
sessionTracker
-
cache
-
-
Constructor Details
-
WorldManager
public WorldManager()
-
-
Method Details
-
init
@PostConstruct public void init() -
get
Get a cached VRObject- Parameters:
id-- Returns:
-
get
-
find
Find some objects, in-memory operation on cache.- Parameters:
filter- Predicate to select objects, e.g. o->o.isActive()- Returns:
-
listClasses
-
getWorld
-
getOrCreateWorld
-
saveWorld
-
deleteWorld
-
getClient
-
getClientByName
-
getCachedClient
If the client is currently active, cached version of the client, otherwise null -
getClientByName
-
save
-
getRange
-
getPermanents
-
add
Add an object to client's current position- Parameters:
client- Client adding objectso- A VRObject- Returns:
- saved VRObject
-
isOwner
-
add
Add objects to client's current position- Parameters:
client- client adding objectsobjects- objects to add- Returns:
- list of added objects
-
remove
-
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 sessionclientClass- either User or RemoteServerclientFactory- either userFactory or serverFactory- Returns:
- See Also:
-
login
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. Sets internal variables on the client, including new instance of scene properties with default values. -
enter
-
enter
-
startSession
The client has set own properties, entered a world, and going online. Starting a session sets client active flag, and creates the scene for the client by calling createScene() method of the Client implementation.- Parameters:
client- a connected Client, typically User, that starts the session- Returns:
- scene size
- Throws:
SessionException- if the client with the same name but different id already exists
-
logout
Called by SessionManager after the client closes the web socket -
dispatch
- Throws:
Exception
-
getStreamManager
CHECKME Commands need access to StreamManager- Returns:
- StreamManager
-
getDb
CHECKME Commands need access to database- Returns:
- VRObjectRepository
-
worldFactory
- Returns:
- world factory
-