Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions configuration-options/game-configuration/storage-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,132 @@ The session storage works just like the local storage engine with the important

## Remote Storage

For remote storage, your configuration in `options.js` can be set as follow.

```javascript
'Storage': {
'Adapter': 'RemoteStorage',
'Store': '',
'Endpoint': 'https://foobar.com/gameSave'
}
```

Or you may add a store name:

```javascript
'Storage': {
'Adapter': 'RemoteStorage',
'Store': 'MyGame',
'Endpoint': 'https://foobar.com/gameSave/'
}
```

The storage engine concats the `Store` and `Endpoint` values as the actual RESTful API **endpoint url** to use:

```
https://foobar.com/gameSave/MyGame
```

### Implementing the Remote Storage

The storage mimic that of a localStorage, which is simple JSON object storage.

The **endpoint url** should implement the below API interface:

---

```http
GET [endpoint url]/
```

{% hint style="info" %}
Normally, retrieves all the values in the space in a key-value JSON object. If previous storage does not exist, return an empty JSON object: `{}`.

In keys-listing mode, return all keys stored in the space as a JSON array.
{% endhint %}

**Parameters**

| Name | Description |
| ---- | ----------- |
| keys | Boolean. If set to `true`, will switch to keys-listing mode. |

---

```http
DELETE [endpoint url]/
```

{% hint style="info" %}
Clear the entire storage object.

Equivlant to
```javascript
localStorage.clear();
```
{% endhint %}

---

```http
GET [endpoint url]/{key}
```

{% hint style="info" %}
Return the value of the key in the storage object.

Equivlant to
```javascript
localStorage.getItem(key);
```
{% endhint %}

---

```http
POST [endpoint url]/{key}
```

{% hint style="info" %}
Store the value in the storage object under the key.

The request body will be the JSON value to store.

Equivlant to
```javascript
localStorage.setItem(key, value);
```
{% endhint %}

---

```http
PUT [endpoint url]/{key}
```

{% hint style="info" %}
Update the value in the storage object under the key.

The request body will be the JSON value to store. The original content
should be overwritten.

Equivlant to
```javascript
localStorage.setItem(key, value);
```
{% endhint %}

---

```http
DELETE [endpoint url]/{key}
```

{% hint style="info" %}
Return the value of the key in the storage object.

Equivlant to
```javascript
localStorage.removeItem(key);
````
{% endhint %}