Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.

Commit

Permalink
Changing CallAsync return signatures.
Browse files Browse the repository at this point in the history
  • Loading branch information
dajuric committed Oct 14, 2017
1 parent 051e219 commit aeb3ba1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Deploy/Nuget/Build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

:: settings
set nugetPath=%cd%\..\..\.nuget
set version=0.5.1
set version=0.8.1
set output=%cd%\bin

:: Create output directory
Expand Down
2 changes: 1 addition & 1 deletion Samples/ServerClientSample/Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void Main(string[] args)
c.OnOpen += async () =>
{
var r = await RPC.For<ILocalAPI>().CallAsync(x => x.LongRunningTask(5, 3));
Console.WriteLine("Result: " + r.First().Result);
Console.WriteLine("Result: " + r.First());
};
})
.Wait(0);
Expand Down
6 changes: 3 additions & 3 deletions Source/WebsocketRPC/ConnectionBinders/Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ public async Task<TResult> CallAsync<TResult>(Expression<Func<TInterface, TResul
return await rInvoker.InvokeAsync(functionExpression);
}

public async Task<Task> CallAsync(Expression<Func<TInterface, Task>> functionExpression)
public async Task CallAsync(Expression<Func<TInterface, Task>> functionExpression)
{
return await rInvoker.InvokeAsync(functionExpression);
await rInvoker.InvokeAsync(functionExpression);
}

public async Task<Task<TResult>> CallAsync<TResult>(Expression<Func<TInterface, Task<TResult>>> functionExpression)
public async Task<TResult> CallAsync<TResult>(Expression<Func<TInterface, Task<TResult>>> functionExpression)
{
return await rInvoker.InvokeAsync(functionExpression);
}
Expand Down
4 changes: 2 additions & 2 deletions Source/WebsocketRPC/ConnectionBinders/BinderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ public interface IRemoteBinder<T> : IBinder
/// </summary>
/// <param name="functionExpression">Method getter.</param>
/// <returns>RPC task result.</returns>
Task<Task> CallAsync(Expression<Func<T, Task>> functionExpression);
Task CallAsync(Expression<Func<T, Task>> functionExpression);

/// <summary>
/// Calls the RPC method.
/// </summary>
/// <typeparam name="TResult">Result.</typeparam>
/// <param name="functionExpression">Method getter.</param>
/// <returns>RPC result.</returns>
Task<Task<TResult>> CallAsync<TResult>(Expression<Func<T, Task<TResult>>> functionExpression);
Task<TResult> CallAsync<TResult>(Expression<Func<T, Task<TResult>>> functionExpression);
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Source/WebsocketRPC/ConnectionBinders/RemoteBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public async Task<TResult> CallAsync<TResult>(Expression<Func<TInterface, TResul
return await rInvoker.InvokeAsync(functionExpression);
}

public async Task<Task> CallAsync(Expression<Func<TInterface, Task>> functionExpression)
public async Task CallAsync(Expression<Func<TInterface, Task>> functionExpression)
{
return await rInvoker.InvokeAsync(functionExpression);
await rInvoker.InvokeAsync(functionExpression);
}

public async Task<Task<TResult>> CallAsync<TResult>(Expression<Func<TInterface, Task<TResult>>> functionExpression)
public async Task<TResult> CallAsync<TResult>(Expression<Func<TInterface, Task<TResult>>> functionExpression)
{
return await rInvoker.InvokeAsync(functionExpression);
}
Expand Down
8 changes: 3 additions & 5 deletions Source/WebsocketRPC/Invokers/RemoteInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,16 @@ public async Task<TResult> InvokeAsync<TResult>(Expression<Func<TInterface, TRes
return result;
}

public async Task<Task> InvokeAsync(Expression<Func<TInterface, Task>> functionExpression)
public async Task InvokeAsync(Expression<Func<TInterface, Task>> functionExpression)
{
var (funcName, argVals) = getFunctionInfo(functionExpression);
var response = await invokeAsync(funcName, argVals);

if (response.Error != null)
throw new Exception(response.Error);

return Task.FromResult(true);
}

public async Task<Task<TResult>> InvokeAsync<TResult>(Expression<Func<TInterface, Task<TResult>>> functionExpression)
public async Task<TResult> InvokeAsync<TResult>(Expression<Func<TInterface, Task<TResult>>> functionExpression)
{
var (funcName, argVals) = getFunctionInfo(functionExpression);
var response = await invokeAsync(funcName, argVals);
Expand All @@ -125,7 +123,7 @@ public async Task<Task<TResult>> InvokeAsync<TResult>(Expression<Func<TInterface
if (response.Error != null)
throw new Exception(response.Error);

return Task.FromResult(result);
return result;
}

async Task<Response> invokeAsync(string name, params object[] args)
Expand Down
4 changes: 2 additions & 2 deletions Source/WebsocketRPC/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ public static async Task CallAsync<TInterface>(this IEnumerable<IRemoteBinder<TI
/// <param name="binders">Remote binder collection.</param>
/// <param name="functionExpression">Method getter.</param>
/// <returns>The collection of results.</returns>
public static async Task<Task<TResult>[]> CallAsync<TInterface, TResult>(this IEnumerable<IRemoteBinder<TInterface>> binders, Expression<Func<TInterface, Task<TResult>>> functionExpression)
public static async Task<TResult[]> CallAsync<TInterface, TResult>(this IEnumerable<IRemoteBinder<TInterface>> binders, Expression<Func<TInterface, Task<TResult>>> functionExpression)
{
var tasks = new List<Task<Task<TResult>>>();
var tasks = new List<Task<TResult>>();
foreach (var b in binders)
{
var t = b.CallAsync(functionExpression);
Expand Down

0 comments on commit aeb3ba1

Please sign in to comment.