Class: VRSpaceAPI

VRSpaceAPI(apiBase)

Class to execute REST API calls, singleton. By default, we're making API calls to the same server that serves the content. This can be changed by providing different apiBase URL to the constructor. All methods are asynchronous but blocking calls.

Constructor

new VRSpaceAPI(apiBase)

Parameters:
Name Type Default Description
apiBase /vrspace/api Base URL for all API endpoint, defaults to /vrspace/api
Source:

Classes

VRSpaceAPI

Methods

(static) getInstance()

Returns VRSpaceAPI instance, creates one if required.
Source:

(async) createWorldFromTemplate(worldName, templateName, isPublic, isTemporary)

Create a world from template
Parameters:
Name Type Default Description
worldName unique world name
templateName optional template name, a world with this name must exist on the server
isPublic false default false, i.e. only invited users (having the token) can enter
isTemporary true default true, i.e. world is deleted once the last user exits
Source:
Returns:
token required to access the world

(async) getAuthenticated()

Returns true if the user is authanticated
Source:

(async) getJson()

Internally used helper method
Source:

(async) getText()

Internally used helper method
Source:

(async) getUserName()

Returns current user name associated with the session.
Source:
Returns:
current user name, or null if user is anonymous (not logged in yet)

(async) getUserObject()

Returns User object of the current user, or null for anonymous users
Source:

(async) listOAuthProviders()

Returns object of provider id: name (e.g. github: GitHub)
Source:

(async) oauth2login(providerId, userName, avatarUrl)

Initiates OAuth2 login with the server - opens login form with Oauth provider. Requires Oauth2 provider id as returned by listOAuthProviders().
Parameters:
Name Type Description
providerId Oauth provider as defined on the server
userName user name
avatarUrl optional Avatar URL
Source:

upload(file, position, rotation)

Upload a file.
Parameters:
Name Type Description
file File object
position an object containing x,y,z (Vector3)
rotation an object containing x,y,z (Vector3)
Source:

(async) verifyName(name)

Verify if given user name is valid, i.e. we can create user with that name.
Parameters:
Name Type Description
name user name
Source:
Returns:
true if user name is available