Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k0dep/Unity-Json-Rpc
:scroll:🖥️Json rpc v1.0 server implementation for Unity3d package
https://github.com/k0dep/Unity-Json-Rpc
json-rpc originer server unity unity3d upm-package
Last synced: 2 months ago
JSON representation
:scroll:🖥️Json rpc v1.0 server implementation for Unity3d package
- Host: GitHub
- URL: https://github.com/k0dep/Unity-Json-Rpc
- Owner: k0dep
- License: mit
- Created: 2019-05-03T22:47:50.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-19T09:48:25.000Z (over 5 years ago)
- Last Synced: 2024-11-12T17:48:11.426Z (3 months ago)
- Topics: json-rpc, originer, server, unity, unity3d, upm-package
- Language: C#
- Homepage:
- Size: 9.77 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
UnityJsonRpc
=========Json-Rpc server for unity as upm package.
Sample
------1. Create `Server.cs` mono behaviour file:
```csharp
using System.Collections.Concurrent;
using UnityEngine;
using UnityJsonRpc;
using Random = UnityEngine.Random;public class Server : MonoBehaviour
{
public int ListenPort = 8080;private JsonRpcServer server;
private ConcurrentQueue requests;
public void Awake()
{
server = new JsonRpcServer();
requests = server.Start("http://localhost:" + ListenPort + "/");
}void Update()
{
if (requests.IsEmpty)
{
return;
}if (requests.TryDequeue(out var request))
{
if (Random.value > 0.5)
{
request.Error(-121276);
}
else
{
request.Respond("ok");
}
}
}
public void OnDestroy()
{
server.Stop();
}
}
```2. Add `Server` component to some GameObject at scene
3. Play
4. Request(by Postman or another app) `http://localhost:8080/` with payload:
```json
{
"method": "method"
}
```
5. Take responseUsing
-----For start using this package add lines into `./Packages/manifest.json` like next sample:
```json
{
"dependencies": {
"unity-json-rpc": "https://github.com/k0dep/unity-json-rpc.git"
}
}
```Or use it as dependency from another packages and auto include by [Originer](https://github.com/k0dep/Originer) package