Package org.vrspace.server.core
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 Summary
Fields Modifier and Type Field Description protected ConcurrentHashMap<ID,Entity>
cache
protected ClientFactory
clientFactory
protected ServerConfig
config
protected com.fasterxml.jackson.databind.ObjectMapper
jackson
protected SceneProperties
sceneProperties
protected SessionTracker
sessionTracker
-
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 positionVRObject
add(Client client, VRObject o)
Add an object to client's current positionWorld
defaultWorld()
void
dispatch(VREvent event)
Welcome
enter(Client client, String worldName)
Welcome
enter(Client client, World world)
List<Entity>
find(Predicate<? super Entity> filter)
Find some objects, in-memory operation on cache.protected VRObject
get(ID id)
Client
getClient(Long id)
Client
getClientByName(String name)
<T extends Client>
TgetClientByName(String name, Class<T> cls)
World
getOrCreateWorld(String name)
Set<VRObject>
getPermanents(Client client)
Set<VRObject>
getRange(Client client, Point from, Point to)
World
getWorld(String name)
void
init()
List<Class<?>>
listClasses()
Welcome
login(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session)
Remote user login over websocket.Welcome
login(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session, Class<? extends Client> clientClass)
Common login procedure for both users and remote servers.void
login(Client client)
Stage 2 of login, executed once client has been identified.void
logout(Client client)
void
remove(Client client, VRObject obj)
<T extends VRObject>
Tsave(T obj)
World
saveWorld(World world)
Welcome
serverLogin(org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator session)
Login for remote serversvoid
startSession(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 VRObject add(Client client, VRObject o)
Add an object to client's current position- Parameters:
client
- Client adding objectso
- A VRObject- Returns:
- saved VRObject
-
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)
-
-