Orizon Rpc
orizon orizon Library update 1y ago

Orizon Rpc

A simple library to call rpc's and receive a response callback

favorite2favorites
thumb_up2upvotes
hard_drive 0 MB folder 15 files build Engine v17 history Last update 556d ago
open_in_new View on sbox.game

About This Package

// Your data model
public struct YourData
{
    public SteamId SteamId { get; set; }
    public string FirstName { get; set;}
}

// Create your struct request
private record struct GetDataRequest : IRpcRequest
{
    public Guid CallbackId { get; set; }
    public int DataId { get; set; }
}

// Create your struct response
private record struct GetDataResponse : IRpcResponse
{
    public Guid CallbackId { get; set; }
    public YourData Data { get; set; }
}

// Called on the host
private static GetDataResponse OnGetDataRequest( GetDataRequest request )
{
    // Do your work here and return the result
    var data = ...

    return new GetDataResponse { Data = data };
}

In your custom script, e.g Character.cs
// Register your rpc callback here
protected override void OnStart()
{
    if ( IsProxy ) return;

    RpcServer.RegisterHandler<GetDataRequest, GetDataResponse>( OnGetDataRequest );
}

// Call this function on the client to get your data
public static async Task<YourData> GetDataAsync( int dataId )
{
    var request = new GetDataRequest { DataId = dataId };
        
    // Your data is store in the result variable
    var result = await RpcClient.SendRpc<GetDataRequest, GetDataResponse>( request );
    return result.Data;
}

Media

No usage statistics available
This package may be new or not widely used yet. Usage data becomes available as more users install and play with the package.
Package ID: orizon.orizon_rpc
Created: 2025-02-05 13:30 UTC
Updated: 2025-02-15 20:48 UTC
Type: library
Public: Yes
Version: 88162
files: 15
Size: 0.0 MB
Engine Version: 17
Asset Version ID: 88162
Version Created: 2025-02-15 20:48 UTC
Hash: 6662336366500011506
Manifest: Open manifest
Compiler: Orizon, SANDBOX;ADDON;DEBUG, 1701;1702;1591;, , , 1, 1, Debug, Array, Array, Array
Resources:
Code Package References:
new_releases Latest Update Feb 15, 2025
Changes on 2025-02-15
88162 Feb 15, 2025
Changes on 2025-02-15
88159 Feb 15, 2025
Changes on 2025-02-15
86750 Feb 8, 2025
Changes on 2025-02-08
86411 Feb 5, 2025
Changes on 2025-02-05