mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
up
This commit is contained in:
parent
65d945e1a1
commit
8bc04389c8
@ -1,18 +1,31 @@
|
|||||||
|
using PlasticPipe.PlasticProtocol.Messages;
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class JsonRpcServer : MonoBehaviour
|
namespace pkpy
|
||||||
{
|
{
|
||||||
// Start is called before the first frame update
|
public abstract class JsonRpcServer
|
||||||
void Start()
|
|
||||||
{
|
{
|
||||||
|
protected abstract Task<string> dispatch(ThreadedVM vm, string request);
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
public async Task attach(ThreadedVM vm)
|
||||||
void Update()
|
{
|
||||||
{
|
while (vm.state <= ThreadState.running) await Task.Yield();
|
||||||
|
switch (vm.state)
|
||||||
|
{
|
||||||
|
case ThreadState.suspended:
|
||||||
|
string request = vm.read_jsonrpc_request();
|
||||||
|
string response = await dispatch(vm, request);
|
||||||
|
vm.write_jsonrpc_response(response);
|
||||||
|
await attach(vm);
|
||||||
|
break;
|
||||||
|
case ThreadState.finished:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception("Unexpected state");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
11
plugins/unity/com.bl.pocketpy/PocketPy.cs.meta
Normal file
11
plugins/unity/com.bl.pocketpy/PocketPy.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dd15753450212f045aa08d30ba3cca6e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user