Implement getServerMetadata method.
This method let the user get the unique name and public IP of its machine during a running session. This let users implement their own communication method for Unreal app for example (using their own server to communicate with their app). ** Update readme
This commit is contained in:
Родитель
3f37eabc2e
Коммит
b0a88f2945
16
README.md
16
README.md
|
@ -133,6 +133,22 @@ player.getServerAvailability(function(data) {
|
|||
});
|
||||
```
|
||||
|
||||
#### getServerMetadata(function(metadata) {}, function(error) {}) asynchronous function
|
||||
Call this function to get unique VM informations.
|
||||
This function return metadata only when a session is running.
|
||||
`metadata: Object`:
|
||||
- `publicIP: String` The VM public IP.
|
||||
- `name: String` A unique name to identify a VM.
|
||||
##### Example:
|
||||
```javascript
|
||||
player.getServerAvailability(function(metadata) {
|
||||
console.log("Public VM IP: ", metadata.publicIP);
|
||||
console.log("VM unique name: ", metadata.name);
|
||||
}, function(error) {
|
||||
// Treat the error.
|
||||
});
|
||||
```
|
||||
|
||||
### Methods to create your own interface
|
||||
Those methods let you create your own interface.
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ const _eventNames = {
|
|||
ON_USER_INACTIVE: "onUserInactive",
|
||||
ON_SESSION_STOPPED: "onSessionStopped",
|
||||
ON_STATS: "onStats",
|
||||
GET_SERVER_AVAILABILITY: "getServerAvailability"
|
||||
GET_SERVER_AVAILABILITY: "getServerAvailability",
|
||||
GET_SERVER_METADATA: "getServerMetadata",
|
||||
};
|
||||
|
||||
const _qualityValues = {
|
||||
|
@ -205,6 +206,25 @@ module.exports = class Player {
|
|||
|
||||
this._getServerAvailabilityCallback(response.stats);
|
||||
return;
|
||||
case _eventNames.GET_SERVER_METADATA:
|
||||
const response = e.data.value;
|
||||
|
||||
if (response.error) {
|
||||
console.log("Error getting server metadata", response.error);
|
||||
if (this._getServerMetadataErrorCallback) {
|
||||
this._getServerMetadataErrorCallback(response.error);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._getServerMetadataCallback) {
|
||||
console.log("No success callback binded !");
|
||||
return;
|
||||
}
|
||||
|
||||
this._getServerMetadataCallback(response.metadata);
|
||||
return;
|
||||
case _eventNames.ERROR:
|
||||
this._displayErrorMessage(e.data.value);
|
||||
return;
|
||||
|
@ -366,4 +386,16 @@ module.exports = class Player {
|
|||
this.embed.contentWindow.postMessage({ type: _eventNames.GET_SERVER_AVAILABILITY }, _furioosServerUrl);
|
||||
// The response will be treat in the listener below.
|
||||
}
|
||||
|
||||
getServerMetadata(getServerMetadataCallback, getServerMetadataErrorCallback) {
|
||||
if (!this.loaded) {
|
||||
return; // Not loaded.
|
||||
}
|
||||
this._getServerMetadataCallback = getServerMetadataCallback;
|
||||
this._getServerMetadataErrorCallback = getServerMetadataErrorCallback;
|
||||
|
||||
// Call the get.
|
||||
this.embed.contentWindow.postMessage({ type: _eventNames.GET_SERVER_METADATA }, _furioosServerUrl);
|
||||
// The response will be treat in the listener below.
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче