呼叫Rpc請求的資料格式: [method, data]

方法1: data是單一值時

public class ReqEcho : CasinoRequest
{
    public override string Method { get { return "echo"; } }

    public ReqEcho()
    {
        SingleValue = "hello world";
    }
}

產出: ["echo", "hello world"]

註:SingleValue適用於只產單一值的時候


方法2: data是object時

public class ReqEcho1 : CasinoRequest
{
    public override string Method { get { return "echo1"; } }

    [JsonName("n")]
    public string Name { get; }
    [JsonName("m")]
    public int Money { get; }

    public ReqEcho1()
    {
        Name = "samliu";
        Money = int.MaxValue;
    }
}

產出: ["echo1", {"n":"samliu","m":2147483647}]


方法3: data是array時

[JsonArray]
public class ReqEcho2 : CasinoRequest
{
    public override string Method { get { return "echo2"; } }

    [JsonName(0)]
    public string Name { get; }
    [JsonName(1)]
    public int Money { get; }

    public ReqEcho2()
    {
        Name = "samliu";
        Money = int.MaxValue;
    }
}

產出: ["echo2",["samliu",2147483647]]

results matching ""

    No results matching ""