Compare commits
No commits in common. "a68d12aab5a0a2e1d1322aae7f3e98de8e4cf937" and "885b27bfe182a0b1e48720eab3d70eabc2f7749f" have entirely different histories.
a68d12aab5
...
885b27bfe1
|
|
@ -1,47 +0,0 @@
|
|||
env:
|
||||
SUBFOLDER: docs_website
|
||||
|
||||
name: Publish Docs to docs.velconnect.ugavel.com (Cloudflare Pages)
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- docs_website/**
|
||||
|
||||
jobs:
|
||||
publish-docs:
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ${{env.SUBFOLDER}}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
deployments: write
|
||||
name: Publish to Cloudflare Pages
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- run: echo "CACHE_ID=$(date --utc '+%V')" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
key: mkdocs-material-${{ env.CACHE_ID }}
|
||||
path: .cache
|
||||
restore-keys: |
|
||||
mkdocs-material-
|
||||
|
||||
- run: pip install -r requirements.txt
|
||||
|
||||
- name: Build
|
||||
run: mkdocs build --site-dir public
|
||||
|
||||
- name: Upload
|
||||
env:
|
||||
PROJECT_NAME: velconnect-docs
|
||||
CLOUDFLARE_ACCOUNT_ID: 8077b5b1f8e2ade41874cbaa3f883069
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
run: npx wrangler@3.1.1 pages deploy public --project-name="${{env.PROJECT_NAME}}" --branch="${{env.GITHUB_REF_NAME}}"
|
||||
|
|
@ -20,6 +20,6 @@ jobs:
|
|||
registry-url: "https://registry.npmjs.org"
|
||||
- run: npm install
|
||||
- run: npm ci
|
||||
- run: npm publish --access public
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ jobs:
|
|||
registry-url: "https://registry.npmjs.org"
|
||||
- run: npm install
|
||||
- run: npm ci
|
||||
- run: npm publish --access public
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
env/
|
||||
public/
|
||||
site/
|
||||
.venv/
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Serve Docs",
|
||||
"type": "node-terminal",
|
||||
"request": "launch",
|
||||
"command": "mkdocs serve"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"python.terminal.activateEnvironment": true,
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Autogenerate docs from code",
|
||||
"detail": "Runs generate_docs.py",
|
||||
"command": "python generate_docs.py",
|
||||
"type": "shell",
|
||||
"args": [],
|
||||
"problemMatcher": [],
|
||||
"presentation": {
|
||||
"reveal": "always"
|
||||
},
|
||||
"group": "build"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# VEL-Connect Docs
|
||||
|
||||
## Setup
|
||||
|
||||
1. Create or activate a pip environment
|
||||
- Create:
|
||||
- `python -m venv env`
|
||||
- Activate:
|
||||
- PowerShell: `.\env\Scripts\Activate.ps1`
|
||||
- CMD: `.\env\Scripts\Activate.bat`
|
||||
2. Install requirements:
|
||||
- `pip install -r requirements.txt`
|
||||
3. Run:
|
||||
- `mkdocs serve`
|
||||
- or use `F5` in VSCode
|
||||
4. Build and Deploy
|
||||
- Building and deploying happens automatically using a GitHub Action on push. If you want to build manually, use this command:
|
||||
- `mkdocs build`
|
||||
- For more information, visit these docs pages: https://squidfunk.github.io/mkdocs-material/getting-started/
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 49 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 659 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 108 KiB |
|
|
@ -1,8 +0,0 @@
|
|||
# VEL-Connect
|
||||
|
||||
VEL-Connect is a persistent shared storage mechanism for Unity projects. It can be used as a key-value store as a networked replacement for PlayerPrefs, to share a profile of user data across multiple devices, or to easily switch between different user profiles on a single device.
|
||||
|
||||
Important pages:
|
||||
|
||||
- [Installation](/installation)
|
||||
- [Quick Start](/quick-start)
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
|
||||
Install the UPM package in Unity:
|
||||
|
||||
=== "**Option 1:** Add the VEL package registry"
|
||||
|
||||
{ align=right }
|
||||
|
||||
Using the scoped registry allows you to easily install a specific version of the package by using the Version History tab.
|
||||
|
||||
- In Unity, go to `Edit->Project Settings...->Package Manager`
|
||||
- Under "Scoped Registries" click the + icon
|
||||
- Add the following details, then click Apply
|
||||
- Name: `VEL` (or anything you want)
|
||||
- URL: `https://npm.ugavel.com`
|
||||
- Scope(s): `edu.uga.engr.vel`
|
||||
- Install the package:
|
||||
- In the package manager, select `My Registries` from the dropdown
|
||||
- Install the `VEL-Connect` package.
|
||||
|
||||
=== "**Option 2:** Add the package by git url"
|
||||
|
||||
1. Open the Package Manager in Unity with `Window->Package Manager`
|
||||
- Add the local package:
|
||||
- `+`->`Add package from git URL...`
|
||||
- Set the path to `https://github.com/velaboratory/VEL-Connect`
|
||||
|
||||
To update the package, click the `Update` button in the Package Manager, or delete the `packages-lock.json` file.
|
||||
|
||||
=== "**Option 3:** Add the package locally"
|
||||
|
||||
1. Clone the repository on your computer:
|
||||
`git clone git@github.com:velaboratory/VEL-Connect.git`
|
||||
- Open the Package Manager in Unity with `Window->Package Manager`
|
||||
- Add the local package:
|
||||
- `+`->`Add package from disk...`
|
||||
- Set the path to `VEL-Connect/package.json` on your hard drive.
|
||||
|
||||
To update the package, use `git pull` in the VEL-Connect folder.
|
||||
|
||||
Then check out the [quick start guide](quick-start.md).
|
||||
|
|
@ -1,180 +0,0 @@
|
|||
---
|
||||
title: Quick Start
|
||||
---
|
||||
|
||||
|
||||
## Setup
|
||||
|
||||
1. [Install the package](/)
|
||||
2. Add the VelConnectManager script to an object in your scene. If you transition between scenes in your application, mark the object as `DontDestroyOnLoad`
|
||||
3. Set the `Vel Connect Url` field on the component to a valid velconnect server. `https://velconnect-v4.ugavel.com` is useful for VEL projects.
|
||||
|
||||
## Usage
|
||||
|
||||
### Setting data
|
||||
|
||||
To set user data in VEL-Connect use the static function `SetUserData`.
|
||||
|
||||
You can add a single key and value:
|
||||
```cs
|
||||
VELConnectManager.SetUserData("key1", "val1");
|
||||
```
|
||||
|
||||
Or set multiple keys with the dictionary syntax:
|
||||
```cs
|
||||
VELConnectManager.SetUserData(new Dictionary<string, string>
|
||||
{
|
||||
{ "key2", "val2" },
|
||||
{ "key3", "val3" }
|
||||
});
|
||||
```
|
||||
Data will be set instantly locally, then pushed to the server. You don't have to wait for VEL-Connect to initialize at the beginning of your game to set data.
|
||||
|
||||
### Getting data
|
||||
|
||||
Fetching data from a remote server can be more tricky because it won't be available immediately when the game starts. Data can also be set from other applications (such as a dashboard or other users in the case of room data), so change listeners are useful.
|
||||
|
||||
To fetch a single value from a key:
|
||||
```cs
|
||||
string value1 = VELConnectManager.GetUserData("key1");
|
||||
```
|
||||
The latest local value will be returned. This will always return null in `Start()` because no data has been fetched yet, so you could wrap this call in the `OnInitialState` callback:
|
||||
```cs
|
||||
VELConnectManager.OnInitialState += state =>
|
||||
{
|
||||
VELConnectManager.GetUserData("key1");
|
||||
};
|
||||
```
|
||||
If the data was already on the server before the start of your application, the correct value will be returned.
|
||||
|
||||
|
||||
#### Change listeners
|
||||
|
||||
If you want to subscribe to changes in a key you can set up change listeners:
|
||||
```cs
|
||||
VELConnectManager.AddUserDataListener("key1", this, value =>
|
||||
{
|
||||
Debug.Log($"key1: {value}");
|
||||
}, true);
|
||||
```
|
||||
Passing in `this` binds the lifetime of the listener to the lifetime of the current script. It is often tedious to make sure to unsubscribe to all of your listeners OnDisable or OnDestroy to prevent the event emitter from sending events to objects that no longer exist, but VEL-Connect will remove listeners when their `keepAliveObject` parameter becomes null. The last parameter in this function (`true` in the example) tells VEL-Connect to activate the callback immediately or when the first value is received. You can add the listener on `Start()` and the first invokation of the callback will have the previous value of the server.
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
Full example:
|
||||
```cs
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using VELConnect;
|
||||
|
||||
public class VELConnectTesting : MonoBehaviour
|
||||
{
|
||||
private IEnumerator Start()
|
||||
{
|
||||
VELConnectManager.OnInitialState += state =>
|
||||
{
|
||||
Debug.Log($"[OnInitialState] key1: {VELConnectManager.GetUserData("key1")}");
|
||||
};
|
||||
|
||||
VELConnectManager.AddUserDataListener("key1", this, value =>
|
||||
{
|
||||
Debug.Log($"[Listener] key1: {value}");
|
||||
}, true);
|
||||
|
||||
VELConnectManager.AddUserDataListener("key2", this, value =>
|
||||
{
|
||||
Debug.Log($"[Listener] key2: {value}");
|
||||
}, false);
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
VELConnectManager.SetUserData("key1", "val1");
|
||||
|
||||
VELConnectManager.SetUserData(new Dictionary<string, string>
|
||||
{
|
||||
{ "key1", "val1" },
|
||||
{ "key2", "val2" },
|
||||
});
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
VELConnectManager.SetUserData("key1", "val1_later");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
JSON.Net Example that illustrates how to persist a complex object of data using VEL-Connect, initializing at start, and saving on application quit
|
||||
|
||||
```cs
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using VELConnect;
|
||||
public class VelConnectDemo1 : MonoBehaviour
|
||||
{
|
||||
class ExampleJSON
|
||||
{
|
||||
public string a_string="a"; //you can use initializers
|
||||
public int a_int=0;
|
||||
public List<ExampleChildJSON> a_list = new List<ExampleChildJSON>(); // you can use lists of objects
|
||||
}
|
||||
class ExampleChildJSON
|
||||
{
|
||||
public string a_string; //if you don't, that's fine too, but you probably want a constructor then
|
||||
public int a_int;
|
||||
public ExampleChildJSON() { } //you need to make sure you have a blank constructor for deserialization
|
||||
public ExampleChildJSON(string a_string, int a_int)
|
||||
{
|
||||
this.a_string = a_string;
|
||||
this.a_int = a_int;
|
||||
}
|
||||
}
|
||||
|
||||
ExampleJSON dataToPersist = null;
|
||||
|
||||
IEnumerator Start()
|
||||
{
|
||||
VELConnectManager.OnInitialState += (state) =>
|
||||
{
|
||||
var s = VELConnectManager.GetUserData("mydata");
|
||||
Debug.Log("Retrieved: " + s);
|
||||
try
|
||||
{
|
||||
dataToPersist = JsonConvert.DeserializeObject<ExampleJSON>(s);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log("Error serializing state: " + e.Message);
|
||||
}
|
||||
if(dataToPersist == null)
|
||||
{
|
||||
Debug.Log("Null state, initializing");
|
||||
dataToPersist =new ExampleJSON();
|
||||
}
|
||||
};
|
||||
|
||||
while (dataToPersist == null) yield return null;
|
||||
|
||||
dataToPersist.a_list.Add(
|
||||
new ExampleChildJSON("" + UnityEngine.Random.Range(0, 10),
|
||||
UnityEngine.Random.Range(0, 10))
|
||||
);
|
||||
Debug.Log(JsonConvert.SerializeObject(dataToPersist));
|
||||
|
||||
}
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
VELConnectManager.SetUserData("mydata", JsonConvert.SerializeObject(dataToPersist));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
:root {
|
||||
--md-primary-fg-color: #7a2020;
|
||||
--md-primary-fg-color--light: #ffffff;
|
||||
--md-primary-fg-color--dark: #e4002b;
|
||||
--md-primary-bg-color: hsla(0, 0%, 100%, 1);
|
||||
--md-primary-bg-color--light: hsla(0, 0%, 100%, 0.7);
|
||||
|
||||
/* --md-accent-fg-color: #ffffff;
|
||||
--md-accent-fg-color--transparent: #ffffff11;
|
||||
--md-accent-bg-color: hsla(0, 0%, 100%, 1);
|
||||
--md-accent-bg-color--light: hsla(0, 0%, 100%, 0.7); */
|
||||
}
|
||||
[data-md-color-scheme="slate"] {
|
||||
--md-hue: 34;
|
||||
--md-default-bg-color: #191818;
|
||||
--md-code-bg-color: #252525;
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
site_name: VEL-Connect Docs
|
||||
site_url: https://docs.velconnect.ugavel.com
|
||||
repo_url: https://github.com/velaboratory/VEL-Connect
|
||||
repo_name: velaboratory/VEL-Connect
|
||||
edit_uri: edit/main/docs_website/docs
|
||||
|
||||
theme:
|
||||
name: material
|
||||
features:
|
||||
- content.action.edit
|
||||
- navigation.instant
|
||||
# - navigation.sections
|
||||
- navigation.expand
|
||||
- navigation.path
|
||||
- navigation.indexes
|
||||
- toc.follow
|
||||
- toc.integrate
|
||||
- content.code.copy
|
||||
|
||||
palette:
|
||||
scheme: slate
|
||||
primary: custom
|
||||
accent: red
|
||||
# background: custom
|
||||
font: false
|
||||
# text: Oswald
|
||||
# text: Merriweather
|
||||
# text: Merriweather Sans
|
||||
logo: assets/vel_logo_3d.png
|
||||
favicon: assets/vel_logo_3d_square.png
|
||||
|
||||
plugins:
|
||||
- search:
|
||||
# - social:
|
||||
# cards_layout_options:
|
||||
# font_family: Oswald
|
||||
- git-revision-date-localized:
|
||||
enable_creation_date: true
|
||||
|
||||
markdown_extensions:
|
||||
- attr_list
|
||||
- md_in_html
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:material.extensions.emoji.twemoji
|
||||
emoji_generator: !!python/name:material.extensions.emoji.to_svg
|
||||
- pymdownx.superfences
|
||||
- pymdownx.tabbed:
|
||||
alternate_style: true
|
||||
- admonition
|
||||
- pymdownx.details
|
||||
- pymdownx.highlight:
|
||||
anchor_linenums: true
|
||||
line_spans: __span
|
||||
pygments_lang_class: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.snippets
|
||||
|
||||
extra_css:
|
||||
- stylesheets/extra.css
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
mkdocs-material
|
||||
mkdocs-git-revision-date-localized-plugin
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
using VelNet;
|
||||
|
||||
namespace VELConnect
|
||||
{
|
||||
public class GenericSpawnedObject : SyncState
|
||||
{
|
||||
private string url;
|
||||
|
||||
private string Url
|
||||
{
|
||||
get => url;
|
||||
set
|
||||
{
|
||||
if (url == value) return;
|
||||
|
||||
url = value;
|
||||
|
||||
if (url.EndsWith(".png") || url.EndsWith(".jpg"))
|
||||
{
|
||||
StartCoroutine(DownloadImage(url));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Invalid image url: " + url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RawImage rawImage;
|
||||
|
||||
public void Init(string dataUrl)
|
||||
{
|
||||
Url = dataUrl;
|
||||
}
|
||||
|
||||
protected override void SendState(BinaryWriter binaryWriter)
|
||||
{
|
||||
binaryWriter.Write(Url);
|
||||
}
|
||||
|
||||
protected override void ReceiveState(BinaryReader binaryReader)
|
||||
{
|
||||
Url = binaryReader.ReadString();
|
||||
}
|
||||
|
||||
private IEnumerator DownloadImage(string downloadUrl)
|
||||
{
|
||||
UnityWebRequest request = UnityWebRequestTexture.GetTexture(downloadUrl);
|
||||
yield return request.SendWebRequest();
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.Log(request.error);
|
||||
yield break;
|
||||
}
|
||||
|
||||
rawImage.texture = ((DownloadHandlerTexture)request.downloadHandler).texture;
|
||||
float aspect = (float)rawImage.texture.width / rawImage.texture.height;
|
||||
Transform t = transform;
|
||||
Vector3 s = t.localScale;
|
||||
s = new Vector3(aspect * s.y, s.y, s.z);
|
||||
t.localScale = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 16f283d9b4aeffc429940a70600d2e5e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -71,7 +71,7 @@ namespace VELConnect
|
|||
|
||||
public class DataBlock
|
||||
{
|
||||
public string id;
|
||||
public readonly string id;
|
||||
public readonly DateTime created;
|
||||
public readonly DateTime updated;
|
||||
public string block_id;
|
||||
|
|
@ -171,18 +171,21 @@ namespace VELConnect
|
|||
|
||||
private void Awake()
|
||||
{
|
||||
velConnectUrl = velConnectUrl.TrimEnd('/');
|
||||
if (instance != null) Debug.LogError("VELConnectManager instance already exists", this);
|
||||
instance = this;
|
||||
|
||||
// Compute device id
|
||||
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
|
||||
StringBuilder sb = new StringBuilder(SystemInfo.deviceUniqueIdentifier);
|
||||
sb.Append(Application.productName);
|
||||
#if UNITY_EDITOR
|
||||
// allows running multiple builds on the same computer
|
||||
// return SystemInfo.deviceUniqueIdentifier + Hash128.Compute(Application.dataPath);
|
||||
sb.Append(Application.dataPath);
|
||||
sb.Append("EDITOR");
|
||||
#endif
|
||||
string id = Convert.ToBase64String(md5.ComputeHash(Encoding.UTF8.GetBytes(sb.ToString())));
|
||||
deviceId = CreateDeviceId();
|
||||
VelNetManager.OnLocalNetworkObjectSpawned += networkObject =>
|
||||
{
|
||||
if (!networkObject.ownershipLocked)
|
||||
{
|
||||
// TODO
|
||||
// SetRoomData("spawned_" + networkObject.networkId, networkObject.prefabName);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Computes 15-char device id compatibly with pocketbase
|
||||
|
|
@ -261,7 +264,25 @@ namespace VELConnect
|
|||
state = JsonConvert.DeserializeObject<State>(json);
|
||||
if (state == null) return;
|
||||
|
||||
bool isInitialState = lastState == null;
|
||||
bool isInitialState = false;
|
||||
|
||||
// first load stuff
|
||||
if (lastState == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
OnInitialState?.Invoke(state);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
}
|
||||
|
||||
isInitialState = true;
|
||||
// lastState = state;
|
||||
// return;
|
||||
}
|
||||
|
||||
|
||||
// if (state.device.modified_by != DeviceId)
|
||||
{
|
||||
|
|
@ -392,7 +413,7 @@ namespace VELConnect
|
|||
foreach (KeyValuePair<string, string> elem in state.room.data)
|
||||
{
|
||||
string oldValue = null;
|
||||
lastState?.room?.data.TryGetValue(elem.Key, out oldValue);
|
||||
lastState?.room.data.TryGetValue(elem.Key, out oldValue);
|
||||
if (elem.Value != oldValue)
|
||||
{
|
||||
try
|
||||
|
|
@ -461,18 +482,6 @@ namespace VELConnect
|
|||
{
|
||||
Debug.LogError("Pairing code nulllll");
|
||||
}
|
||||
|
||||
if (isInitialState)
|
||||
{
|
||||
try
|
||||
{
|
||||
OnInitialState?.Invoke(state);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
@ -680,11 +689,6 @@ namespace VELConnect
|
|||
);
|
||||
}
|
||||
|
||||
public static void SetUserData(string key, string value)
|
||||
{
|
||||
SetUserData(new Dictionary<string, string> { { key, value } });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the 'data' object of the Device table
|
||||
/// </summary>
|
||||
|
|
@ -751,7 +755,6 @@ namespace VELConnect
|
|||
State.DataBlock room = new State.DataBlock
|
||||
{
|
||||
category = "room",
|
||||
modified_by = "Unity",
|
||||
data = data
|
||||
};
|
||||
|
||||
|
|
@ -792,9 +795,6 @@ namespace VELConnect
|
|||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unpairs this device from the current user.
|
||||
/// </summary>
|
||||
public static void Unpair()
|
||||
{
|
||||
if (instance.state?.device != null)
|
||||
|
|
@ -917,7 +917,7 @@ namespace VELConnect
|
|||
case UnityWebRequest.Result.ConnectionError:
|
||||
case UnityWebRequest.Result.DataProcessingError:
|
||||
case UnityWebRequest.Result.ProtocolError:
|
||||
Debug.LogWarning(url + ": Error: " + webRequest.error + "\n" + webRequest.downloadHandler.text + "\n" + Environment.StackTrace);
|
||||
Debug.LogError(url + ": Error: " + webRequest.error + "\n" + webRequest.downloadHandler.text + "\n" + Environment.StackTrace);
|
||||
failureCallback?.Invoke(webRequest.error);
|
||||
break;
|
||||
case UnityWebRequest.Result.Success:
|
||||
|
|
@ -929,41 +929,12 @@ namespace VELConnect
|
|||
webRequest.Dispose();
|
||||
}
|
||||
|
||||
public static void SetDataBlock(State.DataBlock dataBlock, Action<State.DataBlock> successCallback = null)
|
||||
{
|
||||
PostRequestCallback(instance.velConnectUrl + "/api/collections/DataBlock/records", JsonConvert.SerializeObject(dataBlock, Formatting.None,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
}), null, s =>
|
||||
{
|
||||
if (successCallback != null)
|
||||
{
|
||||
State.DataBlock resp = JsonConvert.DeserializeObject<State.DataBlock>(s);
|
||||
successCallback?.Invoke(resp);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setting with a block ID will update the existing block, otherwise it will create a new one
|
||||
/// </summary>
|
||||
/// <param name="blockId"></param>
|
||||
/// <param name="dataBlock"></param>
|
||||
/// <param name="successCallback"></param>
|
||||
public static void SetDataBlock([CanBeNull] string blockId, State.DataBlock dataBlock, Action<State.DataBlock> successCallback = null)
|
||||
public static void SetDataBlock(string blockId, State.DataBlock dataBlock)
|
||||
{
|
||||
PostRequestCallback(instance.velConnectUrl + "/data_block/" + blockId, JsonConvert.SerializeObject(dataBlock, Formatting.None, new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
}), null, s =>
|
||||
{
|
||||
if (successCallback != null)
|
||||
{
|
||||
State.DataBlock resp = JsonConvert.DeserializeObject<State.DataBlock>(s);
|
||||
successCallback?.Invoke(resp);
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public static void GetDataBlock(string blockId, Action<State.DataBlock> successCallback = null, Action<string> failureCallback = null)
|
||||
|
|
|
|||
|
|
@ -1,108 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using VELConnect;
|
||||
using VelNet;
|
||||
|
||||
namespace VELConnect
|
||||
{
|
||||
public class VelConnectPersistenceManager : MonoBehaviour
|
||||
{
|
||||
public static VelConnectPersistenceManager instance;
|
||||
|
||||
public class SpawnedObjectData
|
||||
{
|
||||
public string prefabName;
|
||||
public string base64ObjectData;
|
||||
public string networkId;
|
||||
public int componentIdx;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
VelNetManager.OnJoinedRoom += OnJoinedRoom;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
VelNetManager.OnJoinedRoom -= OnJoinedRoom;
|
||||
}
|
||||
|
||||
private void OnJoinedRoom(string roomName)
|
||||
{
|
||||
if (VelNetManager.Players.Count == 0)
|
||||
{
|
||||
string spawnedObjects = VELConnectManager.GetRoomData("spawned_objects", "[]");
|
||||
List<string> spawnedObjectList = JsonConvert.DeserializeObject<List<string>>(spawnedObjects);
|
||||
List<NetworkObject> spawnedNetworkObjects = new List<NetworkObject>();
|
||||
GetSpawnedObjectData(spawnedObjectList, (list) =>
|
||||
{
|
||||
foreach (SpawnedObjectData obj in list)
|
||||
{
|
||||
NetworkObject spawnedObj = spawnedNetworkObjects.Find(i => i.networkId == obj.networkId);
|
||||
if (spawnedObj == null)
|
||||
{
|
||||
spawnedObj = VelNetManager.NetworkInstantiate(obj.prefabName);
|
||||
spawnedNetworkObjects.Add(spawnedObj);
|
||||
}
|
||||
|
||||
spawnedObj.syncedComponents[obj.componentIdx].ReceiveBytes(Convert.FromBase64String(obj.base64ObjectData));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private class DataBlocksResponse
|
||||
{
|
||||
public List<VELConnectManager.State.DataBlock> items;
|
||||
}
|
||||
|
||||
private static void GetSpawnedObjectData(List<string> spawnedObjectList, Action<List<SpawnedObjectData>> callback)
|
||||
{
|
||||
VELConnectManager.GetRequestCallback($"/api/collections/DataBlock/records?filter=({string.Join(" || ", "id=\"" + spawnedObjectList + "\"")})", (response) =>
|
||||
{
|
||||
DataBlocksResponse parsedResponse = JsonConvert.DeserializeObject<DataBlocksResponse>(response);
|
||||
callback(parsedResponse.items.Select(i => new SpawnedObjectData()
|
||||
{
|
||||
networkId = i.block_id.Split("_")[-1],
|
||||
componentIdx = int.Parse(i.block_id.Split("_").Last()),
|
||||
prefabName = i.TryGetData("name"),
|
||||
base64ObjectData = i.TryGetData("state")
|
||||
}).ToList());
|
||||
});
|
||||
}
|
||||
|
||||
public static void RegisterObject(NetworkObject obj)
|
||||
{
|
||||
instance.StartCoroutine(instance.RegisterObjectCo(obj));
|
||||
}
|
||||
|
||||
private IEnumerator RegisterObjectCo(NetworkObject obj)
|
||||
{
|
||||
// upload all the persisted components, then add those components to the room data
|
||||
VelNetPersist[] persistedComponents = obj.GetComponents<VelNetPersist>();
|
||||
List<VELConnectManager.State.DataBlock> responses = new List<VELConnectManager.State.DataBlock>();
|
||||
double startTime = Time.timeAsDouble;
|
||||
foreach (VelNetPersist velNetPersist in persistedComponents)
|
||||
{
|
||||
velNetPersist.Save(s => { responses.Add(s); });
|
||||
}
|
||||
|
||||
while (responses.Count < persistedComponents.Length && Time.timeAsDouble - startTime < 5)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
VELConnectManager.SetRoomData("spawned_objects", JsonConvert.SerializeObject(responses.Select(i => i.block_id).ToList()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 85006f287450ecc4caedd7925e1198e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using VelNet;
|
||||
|
||||
|
|
@ -9,16 +7,8 @@ namespace VELConnect
|
|||
{
|
||||
public class VelNetPersist : MonoBehaviour
|
||||
{
|
||||
private class ComponentState
|
||||
{
|
||||
public int componentIdx;
|
||||
public string state;
|
||||
}
|
||||
|
||||
public SyncState[] syncStateComponents;
|
||||
|
||||
private string Id => $"{Application.productName}_{VelNetManager.Room}_{syncStateComponents.FirstOrDefault()?.networkObject.sceneNetworkId}";
|
||||
|
||||
public SyncState syncState;
|
||||
private string Id => $"{Application.productName}_{VelNetManager.Room}_{syncState.networkObject.sceneNetworkId}_{syncState.networkObject.syncedComponents.IndexOf(syncState)}";
|
||||
private const float interval = 5f;
|
||||
private double nextUpdate;
|
||||
private bool loading;
|
||||
|
|
@ -29,7 +19,7 @@ namespace VELConnect
|
|||
if (Time.timeAsDouble > nextUpdate && VelNetManager.InRoom && !loading)
|
||||
{
|
||||
nextUpdate = Time.timeAsDouble + interval + UnityEngine.Random.Range(0, interval);
|
||||
if (syncStateComponents.FirstOrDefault()?.networkObject.IsMine == true)
|
||||
if (syncState.networkObject.IsMine)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
|
|
@ -57,75 +47,39 @@ namespace VELConnect
|
|||
if (debugLogs) Debug.Log($"[VelNetPersist] Loading {Id}");
|
||||
VELConnectManager.GetDataBlock(Id, data =>
|
||||
{
|
||||
if (!data.data.TryGetValue("components", out string d))
|
||||
if (!data.data.TryGetValue("state", out string d))
|
||||
{
|
||||
Debug.LogError($"[VelNetPersist] Failed to parse {Id}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
List<ComponentState> componentData = JsonConvert.DeserializeObject<List<ComponentState>>(d);
|
||||
|
||||
if (componentData.Count != syncStateComponents.Length)
|
||||
{
|
||||
Debug.LogError($"[VelNetPersist] Different number of components");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < syncStateComponents.Length; i++)
|
||||
{
|
||||
syncStateComponents[i].UnpackState(Convert.FromBase64String(componentData[i].state));
|
||||
}
|
||||
|
||||
if (debugLogs) Debug.Log($"[VelNetPersist] Loaded {Id}");
|
||||
loading = false;
|
||||
}, s => { loading = false; });
|
||||
}
|
||||
|
||||
|
||||
public void Save(Action<VELConnectManager.State.DataBlock> successCallback = null)
|
||||
{
|
||||
if (debugLogs) Debug.Log($"[VelNetPersist] Saving {Id}");
|
||||
|
||||
if (syncStateComponents.FirstOrDefault()?.networkObject == null)
|
||||
{
|
||||
Debug.LogError("First SyncState doesn't have a NetworkObject", this);
|
||||
return;
|
||||
}
|
||||
|
||||
List<ComponentState> componentData = new List<ComponentState>();
|
||||
foreach (SyncState syncState in syncStateComponents)
|
||||
{
|
||||
if (syncState == null)
|
||||
{
|
||||
Debug.LogError("SyncState is null for Persist", this);
|
||||
return;
|
||||
Debug.LogError("[VelNetPersist] Object doesn't exist anymore");
|
||||
}
|
||||
|
||||
if (syncState.networkObject == null)
|
||||
{
|
||||
Debug.LogError("Network Object is null for SyncState", syncState);
|
||||
return;
|
||||
}
|
||||
|
||||
componentData.Add(new ComponentState()
|
||||
{
|
||||
componentIdx = syncState.networkObject.syncedComponents.IndexOf(syncState),
|
||||
state = Convert.ToBase64String(syncState.PackState())
|
||||
});
|
||||
}
|
||||
syncState.UnpackState(Convert.FromBase64String(d));
|
||||
if (debugLogs) Debug.Log($"[VelNetPersist] Loaded {Id}");
|
||||
loading = false;
|
||||
}, s =>
|
||||
{
|
||||
Debug.LogError(s);
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
if (debugLogs) Debug.Log($"[VelNetPersist] Saving {Id}");
|
||||
VELConnectManager.SetDataBlock(Id, new VELConnectManager.State.DataBlock()
|
||||
{
|
||||
id = Id,
|
||||
block_id = Id,
|
||||
category = "object_persist",
|
||||
data = new Dictionary<string, string>
|
||||
{
|
||||
{ "name", syncStateComponents.FirstOrDefault()?.networkObject.name },
|
||||
{ "components", JsonConvert.SerializeObject(componentData) }
|
||||
{ "name", syncState.networkObject.name },
|
||||
{ "state", Convert.ToBase64String(syncState.PackState()) }
|
||||
}
|
||||
}, s => { successCallback?.Invoke(s); });
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "edu.uga.engr.vel.vel-connect",
|
||||
"displayName": "VEL-Connect",
|
||||
"version": "4.0.8",
|
||||
"version": "4.0.1",
|
||||
"unity": "2019.1",
|
||||
"description": "Web-based configuration for VR applications",
|
||||
"keywords": [],
|
||||
|
|
@ -13,6 +13,6 @@
|
|||
"samples": [],
|
||||
"dependencies": {
|
||||
"com.unity.nuget.newtonsoft-json": "3.0.0",
|
||||
"edu.uga.engr.vel.velnet": "1.3.8"
|
||||
"edu.uga.engr.vel.velnet": "1.1.8"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@velaboratory/velconnect",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@velaboratory/velconnect",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pocketbase": "^0.20.3"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@velaboratory/velconnect",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.0",
|
||||
"description": "Use VEL-Connect with a dashboard",
|
||||
"main": "src/index.js",
|
||||
"files": [
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export type AuthSystemFields<T = never> = {
|
|||
|
||||
// Record types for each collection
|
||||
|
||||
export type DataBlockRecord<Tdata = { [key: string]: any }> = {
|
||||
export type DataBlockRecord<Tdata = unknown> = {
|
||||
block_id?: string
|
||||
category?: string
|
||||
data?: null | Tdata
|
||||
|
|
@ -74,10 +74,10 @@ export type UsersRecord = {
|
|||
}
|
||||
|
||||
// Response types include system fields and match responses from the PocketBase API
|
||||
export type DataBlockResponse<Tdata = { [key: string]: any }, Texpand = unknown> = Required<DataBlockRecord<Tdata>> & BaseSystemFields<Texpand>
|
||||
export type DataBlockResponse<Tdata = unknown, Texpand = unknown> = Required<DataBlockRecord<Tdata>> & BaseSystemFields<Texpand>
|
||||
export type DeviceResponse<Texpand = unknown> = Required<DeviceRecord> & BaseSystemFields<Texpand>
|
||||
export type UserCountResponse<Texpand = unknown> = Required<UserCountRecord> & BaseSystemFields<Texpand>
|
||||
export type UsersResponse<Texpand = { devices: DeviceResponse[]; profiles: DataBlockResponse[] }> = Required<UsersRecord> & AuthSystemFields<Texpand>
|
||||
export type UsersResponse<Texpand = unknown> = Required<UsersRecord> & AuthSystemFields<Texpand>
|
||||
|
||||
// Types containing all Records and Responses, useful for creating typing helper functions
|
||||
|
||||
|
|
|
|||
|
|
@ -1,87 +1,88 @@
|
|||
module velaboratory/velconnect
|
||||
|
||||
go 1.22.1
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/labstack/echo/v5 v5.0.0-20230722203903-ec5b858dab61
|
||||
github.com/pocketbase/dbx v1.10.1
|
||||
github.com/pocketbase/pocketbase v0.22.3
|
||||
github.com/labstack/echo/v5 v5.0.0-20220201181537-ed2888cfa198
|
||||
github.com/pocketbase/dbx v1.10.0
|
||||
github.com/pocketbase/pocketbase v0.16.7
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
||||
github.com/aws/aws-sdk-go v1.50.32 // indirect
|
||||
github.com/aws/aws-sdk-go-v2 v1.25.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/config v1.27.6 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.17.6 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.15.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.8 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.51.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.20.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.28.3 // indirect
|
||||
github.com/aws/smithy-go v1.20.1 // indirect
|
||||
github.com/aws/aws-sdk-go v1.44.289 // indirect
|
||||
github.com/aws/aws-sdk-go-v2 v1.18.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/config v1.18.27 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.13.26 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.70 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.34 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.28 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.26 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.29 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.35.0 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.12.12 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.12 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.19.2 // indirect
|
||||
github.com/aws/smithy-go v1.13.5 // indirect
|
||||
github.com/disintegration/imaging v1.6.2 // indirect
|
||||
github.com/domodwyer/mailyak/v3 v3.6.2 // indirect
|
||||
github.com/domodwyer/mailyak/v3 v3.6.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||
github.com/ganigeorgiev/fexpr v0.4.0 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||
github.com/ganigeorgiev/fexpr v0.3.0 // indirect
|
||||
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/google/wire v0.6.0 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/google/wire v0.5.0 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.11.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.17 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/spf13/cast v1.6.0 // indirect
|
||||
github.com/spf13/cobra v1.8.0 // indirect
|
||||
github.com/spf13/cast v1.5.1 // indirect
|
||||
github.com/spf13/cobra v1.7.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
gocloud.dev v0.36.0 // indirect
|
||||
golang.org/x/crypto v0.21.0 // indirect
|
||||
golang.org/x/image v0.15.0 // indirect
|
||||
golang.org/x/net v0.22.0 // indirect
|
||||
golang.org/x/oauth2 v0.18.0 // indirect
|
||||
golang.org/x/sync v0.6.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
golang.org/x/term v0.18.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
|
||||
google.golang.org/api v0.168.0 // indirect
|
||||
google.golang.org/appengine v1.6.8 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 // indirect
|
||||
google.golang.org/grpc v1.62.1 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect
|
||||
modernc.org/libc v1.41.0 // indirect
|
||||
modernc.org/mathutil v1.6.0 // indirect
|
||||
modernc.org/memory v1.7.2 // indirect
|
||||
modernc.org/sqlite v1.29.2 // indirect
|
||||
modernc.org/strutil v1.2.0 // indirect
|
||||
gocloud.dev v0.30.0 // indirect
|
||||
golang.org/x/crypto v0.10.0 // indirect
|
||||
golang.org/x/image v0.8.0 // indirect
|
||||
golang.org/x/mod v0.11.0 // indirect
|
||||
golang.org/x/net v0.11.0 // indirect
|
||||
golang.org/x/oauth2 v0.9.0 // indirect
|
||||
golang.org/x/sys v0.9.0 // indirect
|
||||
golang.org/x/term v0.9.0 // indirect
|
||||
golang.org/x/text v0.10.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
golang.org/x/tools v0.10.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
||||
google.golang.org/api v0.128.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
google.golang.org/grpc v1.56.1 // indirect
|
||||
google.golang.org/protobuf v1.30.0 // indirect
|
||||
lukechampine.com/uint128 v1.3.0 // indirect
|
||||
modernc.org/cc/v3 v3.41.0 // indirect
|
||||
modernc.org/ccgo/v3 v3.16.14 // indirect
|
||||
modernc.org/libc v1.24.1 // indirect
|
||||
modernc.org/mathutil v1.5.0 // indirect
|
||||
modernc.org/memory v1.6.0 // indirect
|
||||
modernc.org/opt v0.1.3 // indirect
|
||||
modernc.org/sqlite v1.23.1 // indirect
|
||||
modernc.org/strutil v1.1.3 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
)
|
||||
|
|
|
|||
3305
velconnect/go.sum
3305
velconnect/go.sum
File diff suppressed because it is too large
Load Diff
|
|
@ -4,8 +4,6 @@ import (
|
|||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
_ "velaboratory/velconnect/pb_migrations"
|
||||
|
||||
|
|
@ -21,18 +19,16 @@ func main() {
|
|||
app := pocketbase.New()
|
||||
|
||||
// loosely check if it was executed using "go run"
|
||||
isGoRun := strings.HasPrefix(os.Args[0], os.TempDir())
|
||||
// isGoRun := strings.HasPrefix(os.Args[0], os.TempDir())
|
||||
|
||||
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
|
||||
// enable auto creation of migration files when making collection changes in the Admin UI
|
||||
migratecmd.MustRegister(app, app.RootCmd, &migratecmd.Options{
|
||||
// enable auto creation of migration files when making collection changes
|
||||
// (the isGoRun check is to enable it only during development)
|
||||
Automigrate: isGoRun,
|
||||
Automigrate: true,
|
||||
})
|
||||
|
||||
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
||||
// or you can also use the shorter e.Router.GET("/articles/:slug", handler, middlewares...)
|
||||
e.Router.GET("/*", apis.StaticDirectoryHandler(os.DirFS("./pb_public"), false))
|
||||
|
||||
e.Router.POST("/data_block/:block_id", func(c echo.Context) error {
|
||||
|
||||
dao := app.Dao()
|
||||
|
|
@ -264,7 +260,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func mergeDataBlock(requestData *models.RequestInfo, record *models.Record) {
|
||||
func mergeDataBlock(requestData *models.RequestData, record *models.Record) {
|
||||
|
||||
// get the new data
|
||||
newData, hasNewData := requestData.Data["data"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue