Skip to content

Commit 721b8d2

Browse files
committed
Ensured RPC results only gets casted once
1 parent fe62410 commit 721b8d2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

MLAPI/Data/RpcResponse.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ namespace MLAPI
99
public class RpcResponse<T> : RpcResponseBase
1010
{
1111
/// <summary>
12-
/// Gets the value from the operation.
13-
/// Note that this is an expensive operation, grab and cache
12+
/// Gets the return value of the operation
1413
/// </summary>
15-
public T Value => Result == null ? default(T) : (T) Result;
14+
public T Value { get; private set; }
15+
16+
internal override object Result
17+
{
18+
set => Value = (T) value;
19+
}
1620
}
1721

1822
/// <summary>
@@ -41,7 +45,7 @@ public abstract class RpcResponseBase
4145
/// The amount of time to wait for the operation to complete
4246
/// </summary>
4347
public float Timeout { get; set; } = 10f;
44-
internal object Result { get; set; }
48+
internal abstract object Result { set; }
4549
internal Type Type { get; set; }
4650
}
4751
}

0 commit comments

Comments
 (0)