Package org.vrspace.client
Class VRSpaceClient
java.lang.Object
org.vrspace.client.VRSpaceClient
- All Implemented Interfaces:
Runnable
,WebSocket.Listener
A simple vrspace websocket client.
- Author:
- joe
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddErrorListener
(Consumer<String> listener) Add an error listener that is passed JSON error message received from the server.addEventListener
(Consumer<VREvent> listener) Add event listener to receive events from the server (changes to VRObjects)addMessageListener
(Consumer<String> listener) Add a listener that receives all text messages from the serveraddSceneListener
(Consumer<SceneChange> listener) Add scene listener that receives changes to the scene - Add and Remove commands.addWelcomeListener
(Consumer<Welcome> listener) Welcome messages are received after connecting and entering a worldvoid
await
(CountDownLatch latch) Hack, awaits for welcome messageconnect()
void
connectAndEnter
(String world) void
connectAndEnterAsync
(String world, Map<String, String> params) Connect, and then set own parameters (e.g.void
connectAndEnterSync
(String world, Map<String, String> params) Connect, set own parameters (e.g.void
void
enterAsync
(String world) Enter a world, do not wait for Welcome responsevoid
Enter a world, and wait for welcomeint
void
void
onPing
(WebSocket webSocket, ByteBuffer message) onText
(WebSocket webSocket, CharSequence data, boolean last) void
run()
void
Send a json string to the serversend
(ClientRequest req) Send a requestvoid
Send a commandvoid
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.net.http.WebSocket.Listener
onBinary, onPong
-
Field Details
-
TIMEOUT
public static final long TIMEOUT- See Also:
-
RETRY
public static final long RETRY- See Also:
-
-
Constructor Details
-
VRSpaceClient
-
-
Method Details
-
connect
-
startSession
public void startSession() -
connectAndEnter
-
disconnect
public void disconnect() -
run
public void run() -
connectAndEnterAsync
Connect, and then set own parameters (e.g. avatar), then enter a world. Does not block until the connection has been made, but returns immediately. Use case - stress testing.- Parameters:
world
- name of the world to enterparams
- own properties to set before entering the world
-
connectAndEnterSync
Connect, set own parameters (e.g. avatar), then enter a world. Wait for connection and session to be set up, and then return. Typical use case when connecting to a server.- Parameters:
world
- name of the world to enterparams
- own properties to set before entering the world
-
addEventListener
Add event listener to receive events from the server (changes to VRObjects) -
addSceneListener
Add scene listener that receives changes to the scene - Add and Remove commands. -
addErrorListener
Add an error listener that is passed JSON error message received from the server. -
addMessageListener
Add a listener that receives all text messages from the server -
addWelcomeListener
Welcome messages are received after connecting and entering a world -
await
Hack, awaits for welcome message -
getClient
-
enterSync
Enter a world, and wait for welcome -
enterAsync
Enter a world, do not wait for Welcome response -
send
Send a json string to the server -
send
Send a request -
send
Send a command -
getErrorCount
public int getErrorCount() -
onOpen
- Specified by:
onOpen
in interfaceWebSocket.Listener
-
onText
- Specified by:
onText
in interfaceWebSocket.Listener
-
onError
- Specified by:
onError
in interfaceWebSocket.Listener
-
onPing
- Specified by:
onPing
in interfaceWebSocket.Listener
-
onClose
- Specified by:
onClose
in interfaceWebSocket.Listener
-