Class: VRSpaceAPI

VRSpaceAPI(apiBaseopt, apiPathopt)

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(apiBaseopt, apiPathopt)

Parameters:
Name Type Attributes Default Description
apiBase string <optional>
"" Base URL for all API endpoint, origin (protocol+host)
apiPath string <optional>
"/vrspace/api" Path component of the API URL
Source:

Classes

VRSpaceAPI

Methods

(static) getInstance(apiBaseopt, apiPathopt) → {VRSpaceAPI}

Returns VRSpaceAPI instance, creates one if required.
Parameters:
Name Type Attributes Description
apiBase String | null <optional>
API URL base
apiPath String | null <optional>
API URL path
Source:
Returns:
Type
VRSpaceAPI

(async) createWorldFromTemplate(worldName, templateName, isPublicopt, isTemporaryopt)

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

(async) getAuthenticated() → {Promise.<boolean>}

Returns true if the user is authanticated
Source:
Returns:
Type
Promise.<boolean>

(async) getUserName() → {String|null}

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

(async) getUserObject() → {Promise.<(User|null)>}

Returns User object of the current user, or null for anonymous users
Source:
Returns:
Type
Promise.<(User|null)>

(async) listOAuthProviders()

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

(async) oauth2login(providerId, userName, avatarUrlopt)

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

upload(file, position, rotation)

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

(async) verifyName(name) → {boolean}

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

webpushSubscribe(clientUrl)

Subcribe to web push, if available on the server. Requires existing service worker, registered in main html file onload function. Fails silently if the registration does not exist.
Parameters:
Name Type Description
clientUrl String path to serviceworker.js
Source:

webpushUnsubscribe(clientUrl)

Unsubcribe from web push notifications, if available and subscribed. Requires existing service worker, registered in main html file onload function. Fails silently if the not subscribed.
Parameters:
Name Type Description
clientUrl String path to serviceworker.js
Source: