diff --git a/Deploy/Nuget/Build.cmd b/Deploy/Nuget/Build.cmd
deleted file mode 100644
index a395daa..0000000
--- a/Deploy/Nuget/Build.cmd
+++ /dev/null
@@ -1,31 +0,0 @@
-::
-@echo off
-:: timeout /T 5
-
-:: settings
-set nugetPath=%cd%\..\..\.nuget
-set version=1.0.3
-set output=%cd%\bin
-
-:: Create output directory
-IF NOT EXIST "%output%\" (
- mkdir "%output%"
-)
-
-:: Remove old files
-echo.
-echo Remvoing old packages:
-for /r %%f in (*.nupkg) do (
- echo %%f
- del "%%f"
-)
-
-echo.
-echo Creating packages for:
-for /r %%f in (*.nuspec) do (
- echo %%f
- "%nugetPath%\nuget.exe" pack "%%f" -Version %version% -OutputDirectory "%output%" -Verbosity quiet
-)
-
-echo.
-pause
\ No newline at end of file
diff --git a/Deploy/Nuget/Push.cmd b/Deploy/Nuget/Push.cmd
index 996bcaf..8c0e2c1 100644
--- a/Deploy/Nuget/Push.cmd
+++ b/Deploy/Nuget/Push.cmd
@@ -5,6 +5,11 @@ timeout /T 5
:: settings
set nugetPath=%cd%\..\..\.nuget
+::update NuGet
+attrib -R "%nugetPath%\nuget.exe"
+echo Updating NuGet...
+"%nugetPath%\nuget.exe" update -Self
+
echo.
echo Pushing packages:
for /r %%f in (*.nupkg) do (
diff --git a/Deploy/Nuget/UpdateNuGet.cmd b/Deploy/Nuget/UpdateNuGet.cmd
deleted file mode 100644
index 8364212..0000000
--- a/Deploy/Nuget/UpdateNuGet.cmd
+++ /dev/null
@@ -1,13 +0,0 @@
-::
-@echo off
-set nugetPath=%cd%\..\.nuget
-
-:: Make sure the nuget executable is writable
-attrib -R "%nugetPath%\nuget.exe"
-
-echo.
-echo Updating NuGet...
-"%nugetPath%\nuget.exe" update -Self
-
-echo.
-pause
\ No newline at end of file
diff --git a/Deploy/Nuget/nuSpecs/WebsocketRPC.JS.nuspec b/Deploy/Nuget/nuSpecs/WebsocketRPC.JS.nuspec
deleted file mode 100644
index 55f2fe4..0000000
--- a/Deploy/Nuget/nuSpecs/WebsocketRPC.JS.nuspec
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
- WebsocketRPC.JS
- $version$
- WebsocketRPC.JS
- Darko Jurić
- Darko Jurić
- https://raw.githubusercontent.com/dajuric/websocket-rpc/master/LICENSE.md
- https://raw.githubusercontent.com/dajuric/websocket-rpc/master/Deploy/Logo/Logo-small.png
- Generates the Javascript code for websocket-connection using the provided .NET interface.
- Generates the Javascript code for websocket-connection using the provided .NET interface.
- websocket; websocket-client; Javascript; RPC; C#; .NET
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Deploy/Nuget/nuSpecs/WebsocketRPC.nuspec b/Deploy/Nuget/nuSpecs/WebsocketRPC.nuspec
deleted file mode 100644
index 9e421f9..0000000
--- a/Deploy/Nuget/nuSpecs/WebsocketRPC.nuspec
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
- WebsocketRPC
- $version$
- WebsocketRPC
- Darko Jurić
- Darko Jurić
- https://raw.githubusercontent.com/dajuric/websocket-rpc/master/LICENSE.md
- https://raw.githubusercontent.com/dajuric/websocket-rpc/master/Deploy/Logo/Logo-small.png
- Provides full duplex RPC over websocket.
- Provides full duplex RPC over websocket.
- websocket; websocket-server; websocket-client; RPC; C#; .NET
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Samples/AspRpc/AspRpc.csproj b/Samples/AspRpc/AspRpc.csproj
new file mode 100644
index 0000000..68d6ea6
--- /dev/null
+++ b/Samples/AspRpc/AspRpc.csproj
@@ -0,0 +1,32 @@
+
+
+
+ netcoreapp2.0;net47
+
+
+
+ bin\
+ bin\netcoreapp2.0\AspRpc.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/AspRpc/Controllers/HomeController.cs b/Samples/AspRpc/Controllers/HomeController.cs
new file mode 100644
index 0000000..0271b29
--- /dev/null
+++ b/Samples/AspRpc/Controllers/HomeController.cs
@@ -0,0 +1,32 @@
+using Microsoft.AspNetCore.Mvc;
+
+namespace AspRpc.Controllers
+{
+ ///
+ /// Home controller.
+ ///
+ [Route("/")]
+ public class HomeController
+ {
+ ///
+ /// Gets the home page.
+ ///
+ /// Home page HTML code.
+ [HttpGet]
+ public RedirectResult Get()
+ {
+ return new RedirectResult("/Site/Index.html");
+ }
+
+ ///
+ /// Gets the fav-icon.
+ ///
+ /// Fav-icon.
+ [HttpGet]
+ [Route("/favicon.ico")]
+ public object GetFavIcon()
+ {
+ return null;
+ }
+ }
+}
diff --git a/Samples/AspRpc/Program.cs b/Samples/AspRpc/Program.cs
new file mode 100644
index 0000000..f0f294e
--- /dev/null
+++ b/Samples/AspRpc/Program.cs
@@ -0,0 +1,64 @@
+using Microsoft.AspNetCore;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.FileProviders;
+using System;
+using System.IO;
+using System.Net.WebSockets;
+using WebSocketRPC;
+
+namespace AspRpc
+{
+ class Startup
+ {
+ ReportingService reportingService = null;
+
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ public IConfiguration Configuration { get; }
+
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddMvcCore();
+ }
+
+ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ }
+
+
+ app.UseMvc();
+ app.UseStaticFiles(new StaticFileOptions
+ {
+ FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "Site")),
+ RequestPath = "/Site"
+ });
+
+ reportingService = new ReportingService();
+ app.UseWebSockets();
+ app.MapWebSocketRPC("/reportingService", (hc, c) => c.Bind(reportingService));
+ }
+ }
+
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ //generate js code
+ File.WriteAllText($"./Site/{nameof(ReportingService)}.js", RPCJs.GenerateCallerWithDoc());
+
+ WebHost.CreateDefaultBuilder(args)
+ .UseStartup()
+ .Build()
+ .Run();
+ }
+ }
+}
diff --git a/Samples/AspRpc/Properties/launchSettings.json b/Samples/AspRpc/Properties/launchSettings.json
new file mode 100644
index 0000000..47281e8
--- /dev/null
+++ b/Samples/AspRpc/Properties/launchSettings.json
@@ -0,0 +1,16 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true
+ },
+ "profiles": {
+ "AspRpc": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "applicationUrl": "http://localhost:8000/"
+ }
+ }
+}
\ No newline at end of file
diff --git a/Samples/AspRpc/Site/Index.html b/Samples/AspRpc/Site/Index.html
new file mode 100644
index 0000000..557b85e
--- /dev/null
+++ b/Samples/AspRpc/Site/Index.html
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/AspRpc/SocketServices/ReportingService.cs b/Samples/AspRpc/SocketServices/ReportingService.cs
new file mode 100644
index 0000000..19ff598
--- /dev/null
+++ b/Samples/AspRpc/SocketServices/ReportingService.cs
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using WebSocketRPC;
+
+namespace AspRpc
+{
+ interface IClientUpdate
+ {
+ void Write(string message);
+
+ void OnStart();
+
+ void OnStop();
+ }
+
+ ///
+ /// Reporting service.
+ ///
+ class ReportingService
+ {
+ CancellationTokenSource cts = null;
+ Task reportTask = null;
+
+ ///
+ /// Starts the reporting service.
+ ///
+ /// Task.
+ ///
+ public async Task Start()
+ {
+ if (reportTask != null)
+ throw new NotSupportedException("The service is running. Please stop it first.");
+
+ await RPC.For().CallAsync(x => x.OnStart());
+ cts = new CancellationTokenSource();
+ reportTask = startReporting(cts.Token);
+ }
+
+ int i = 0;
+ async Task startReporting(CancellationToken ct)
+ {
+ while (!ct.IsCancellationRequested)
+ {
+ await RPC.For().CallAsync(x => x.Write(" Reporting: " + i));
+ await Task.Delay(250);
+ i++;
+ }
+ }
+
+ ///
+ /// Gets whether the service is running or not.
+ ///
+ /// True if the service is running, false otherwise.
+ public bool IsRunning()
+ {
+ return reportTask !=null;
+ }
+
+ ///
+ /// Stops the reporting service.
+ ///
+ /// Task
+ ///
+ public async Task Stop()
+ {
+ if (cts == null)
+ throw new NotSupportedException("The service is stopped. Please start it first.");
+
+ cts?.Cancel();
+ await reportTask;
+ reportTask = null;
+
+ await RPC.For().CallAsync(x => x.OnStop());
+ }
+ }
+}
diff --git a/Samples/AspRpc/appsettings.Development.json b/Samples/AspRpc/appsettings.Development.json
new file mode 100644
index 0000000..fa8ce71
--- /dev/null
+++ b/Samples/AspRpc/appsettings.Development.json
@@ -0,0 +1,10 @@
+{
+ "Logging": {
+ "IncludeScopes": false,
+ "LogLevel": {
+ "Default": "Debug",
+ "System": "Information",
+ "Microsoft": "Information"
+ }
+ }
+}
diff --git a/Samples/AspRpc/appsettings.json b/Samples/AspRpc/appsettings.json
new file mode 100644
index 0000000..26bb0ac
--- /dev/null
+++ b/Samples/AspRpc/appsettings.json
@@ -0,0 +1,15 @@
+{
+ "Logging": {
+ "IncludeScopes": false,
+ "Debug": {
+ "LogLevel": {
+ "Default": "Warning"
+ }
+ },
+ "Console": {
+ "LogLevel": {
+ "Default": "Warning"
+ }
+ }
+ }
+}
diff --git a/Samples/ClientJs/Program.cs b/Samples/ClientJs/Program.cs
index 0f2fa5f..3c6ffae 100644
--- a/Samples/ClientJs/Program.cs
+++ b/Samples/ClientJs/Program.cs
@@ -2,7 +2,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
-using WebsocketRPC;
+using WebSocketRPC;
namespace TestClientJs
{
diff --git a/Samples/ClientJs/ServerClientJs.csproj b/Samples/ClientJs/ServerClientJs.csproj
index 82638f2..74988bd 100644
--- a/Samples/ClientJs/ServerClientJs.csproj
+++ b/Samples/ClientJs/ServerClientJs.csproj
@@ -1,63 +1,24 @@
-
-
-
-
- Debug
- AnyCPU
- {C0449FA5-C667-4B5C-878A-04773903B130}
- Exe
- Properties
- ClientJs
- ClientJs
- v4.7
- 512
-
+
+
+ netcoreapp2.0;net47
+
+
+
+ bin\
-
- true
- full
- false
- bin\
- DEBUG;TRACE
- prompt
- 4
- false
- bin\ClientJs.xml
-
-
- pdbonly
- true
- bin\
- TRACE
- prompt
- 4
- false
- bin\ClientJs.xml
-
-
-
-
-
-
-
-
-
-
-
-
- {965791bf-8f77-4a69-97e2-8b6b66cf9863}
- WebSocketRPC.JS
-
-
- {AB4A5DDF-1F91-4AF8-9E9C-242832576C5E}
- WebsocketRPC
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+ Never
+
+
\ No newline at end of file
diff --git a/Samples/MultiService/MultiService.csproj b/Samples/MultiService/MultiService.csproj
index b8ab050..e2d40c2 100644
--- a/Samples/MultiService/MultiService.csproj
+++ b/Samples/MultiService/MultiService.csproj
@@ -1,62 +1,22 @@
-
-
-
-
- Debug
- AnyCPU
- {2B69F62E-991C-4E4B-B1FF-2A5906415764}
- Exe
- Properties
- ClientJsMultiService
- ClientJsMultiService
- v4.7
- 512
-
-
-
- true
- full
- false
- bin\
- DEBUG;TRACE
- prompt
- 4
- bin\ClientJsMultiService.xml
-
-
- pdbonly
- true
- bin\
- TRACE
- prompt
- 4
- bin\ClientJsMultiService.xml
-
-
-
-
-
-
-
-
-
-
-
-
-
- {965791bf-8f77-4a69-97e2-8b6b66cf9863}
- WebSocketRPC.JS
-
-
- {ab4a5ddf-1f91-4af8-9e9c-242832576c5e}
- WebsocketRPC
-
-
-
-
-
-
-
-
-
+
+
+ netcoreapp2.0;net47
+
+
+
+ bin\
+
+
+
+
+
+
+
+
+
+
+
+ Never
+
+
\ No newline at end of file
diff --git a/Samples/MultiService/Program.cs b/Samples/MultiService/Program.cs
index 6d3c5e7..318a187 100644
--- a/Samples/MultiService/Program.cs
+++ b/Samples/MultiService/Program.cs
@@ -1,7 +1,7 @@
using System;
using System.IO;
using System.Threading;
-using WebsocketRPC;
+using WebSocketRPC;
namespace ClientJsMultiService
{
diff --git a/Samples/Serialization/Program.cs b/Samples/Serialization/Program.cs
index 4d3f977..f978e85 100644
--- a/Samples/Serialization/Program.cs
+++ b/Samples/Serialization/Program.cs
@@ -4,7 +4,7 @@
using System.IO;
using System.Linq;
using System.Threading;
-using WebsocketRPC;
+using WebSocketRPC;
using System.Runtime.CompilerServices;
namespace ServerClientJsSerialization
diff --git a/Samples/Serialization/Serialization.csproj b/Samples/Serialization/Serialization.csproj
index e76d994..b870365 100644
--- a/Samples/Serialization/Serialization.csproj
+++ b/Samples/Serialization/Serialization.csproj
@@ -1,97 +1,32 @@
-
-
-
-
- Debug
- AnyCPU
- {9F82F6DD-238B-4F65-A95C-55F2BA20F1B0}
- Exe
- ServerClientJsSerialization
- ServerClientJsSerialization
- v4.7
- 512
- true
-
-
-
-
-
- AnyCPU
- true
- full
- false
- bin\
- DEBUG;TRACE
- prompt
- 4
- false
- true
- bin\ServerClientJsSerialization.xml
-
-
- AnyCPU
- pdbonly
- true
- bin\
- TRACE
- prompt
- 4
- false
- true
- bin\ServerClientJsSerialization.xml
-
-
-
- ..\..\packages\DotImaging.GenericImage.4.8.3\lib\net45\DotImaging.GenericImage.dll
-
-
- ..\..\packages\DotImaging.IO.4.8.3\lib\net45\DotImaging.IO.dll
-
-
- ..\..\packages\DotImaging.IO.Web.4.8.3\lib\net45\DotImaging.IO.Web.dll
-
-
- ..\..\packages\DotImaging.Primitives2D.4.8.3\lib\net45\DotImaging.Primitives2D.dll
-
-
- ..\..\packages\VideoLibrary.1.3.3\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\libvideo.dll
-
-
- ..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
-
-
-
- ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.4.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
-
-
-
-
-
-
-
- {965791bf-8f77-4a69-97e2-8b6b66cf9863}
- WebSocketRPC.JS
-
-
- {ab4a5ddf-1f91-4af8-9e9c-242832576c5e}
- WebsocketRPC
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+ net47
-
-
+
+
+ bin\
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Never
+
+
\ No newline at end of file
diff --git a/Samples/ServerClientSample/Client/Client.csproj b/Samples/ServerClientSample/Client/Client.csproj
index 4dfa062..1ba5e75 100644
--- a/Samples/ServerClientSample/Client/Client.csproj
+++ b/Samples/ServerClientSample/Client/Client.csproj
@@ -1,54 +1,13 @@
-
-
-
-
- Debug
- AnyCPU
- {E0DBB446-3B2B-4BC2-871F-925AB60917E3}
- Exe
- Properties
- Client
- Client
- v4.7
- 512
-
-
-
- true
- full
- false
- bin\
- DEBUG;TRACE
- prompt
- 4
- false
-
-
- pdbonly
- true
- bin\
- TRACE
- prompt
- 4
- false
-
-
-
-
-
-
-
-
-
-
-
-
- {ab4a5ddf-1f91-4af8-9e9c-242832576c5e}
- WebsocketRPC
-
-
-
-
-
-
+
+
+ netcoreapp2.0;net47
+
+
+
+ bin\
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/ServerClientSample/Client/Program.cs b/Samples/ServerClientSample/Client/Program.cs
index 5f3f575..8ca4a47 100644
--- a/Samples/ServerClientSample/Client/Program.cs
+++ b/Samples/ServerClientSample/Client/Program.cs
@@ -2,7 +2,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using WebsocketRPC;
+using WebSocketRPC;
namespace TestClient
{
diff --git a/Samples/ServerClientSample/Server/Program.cs b/Samples/ServerClientSample/Server/Program.cs
index 8ddcfa7..7099c2f 100644
--- a/Samples/ServerClientSample/Server/Program.cs
+++ b/Samples/ServerClientSample/Server/Program.cs
@@ -1,7 +1,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
-using WebsocketRPC;
+using WebSocketRPC;
namespace TestServer
{
diff --git a/Samples/ServerClientSample/Server/Server.csproj b/Samples/ServerClientSample/Server/Server.csproj
index fc26b37..1ba5e75 100644
--- a/Samples/ServerClientSample/Server/Server.csproj
+++ b/Samples/ServerClientSample/Server/Server.csproj
@@ -1,54 +1,13 @@
-
-
-
-
- Debug
- AnyCPU
- {841054C8-559B-4E6F-8DCD-44C2D3DA2F0B}
- Exe
- Properties
- Server
- Server
- v4.7
- 512
-
-
-
- true
- full
- false
- bin\
- DEBUG;TRACE
- prompt
- 4
- false
-
-
- pdbonly
- true
- bin\
- TRACE
- prompt
- 4
- false
-
-
-
-
-
-
-
-
-
-
-
-
- {ab4a5ddf-1f91-4af8-9e9c-242832576c5e}
- WebsocketRPC
-
-
-
-
-
-
+
+
+ netcoreapp2.0;net47
+
+
+
+ bin\
+
+
+
+
+
\ No newline at end of file
diff --git a/Source/WebSocketRPC.AspCore/WebSocketRPC.AspCore.csproj b/Source/WebSocketRPC.AspCore/WebSocketRPC.AspCore.csproj
new file mode 100644
index 0000000..7b70f0b
--- /dev/null
+++ b/Source/WebSocketRPC.AspCore/WebSocketRPC.AspCore.csproj
@@ -0,0 +1,40 @@
+
+
+
+ netcoreapp2.0;net47
+
+
+
+ bin\
+
+
+
+ bin\$(TargetFramework)\WebsocketRPC.AspCore.xml
+ true
+
+
+
+
+
+
+
+
+
+
+
+ Darko Jurić
+ WebSocket RPC for ASP.NET Core.
+ Darko Jurić
+ https://raw.githubusercontent.com/dajuric/websocket-rpc/master/LICENSE.md
+ https://raw.githubusercontent.com/dajuric/websocket-rpc/master/Deploy/Logo/Logo-small.png
+ https://github.com/dajuric/websocket-rpc/
+ https://github.com/dajuric/websocket-rpc/
+ websocket; ASP.NET; RPC; C#; .NET
+ true
+
+ 1.0.0
+ ../../Deploy/Nuget/bin/
+ WebSocketRPC
+
+
+
diff --git a/Source/WebSocketRPC.AspCore/WebSokcetRPCMiddleware.cs b/Source/WebSocketRPC.AspCore/WebSokcetRPCMiddleware.cs
new file mode 100644
index 0000000..da442c8
--- /dev/null
+++ b/Source/WebSocketRPC.AspCore/WebSokcetRPCMiddleware.cs
@@ -0,0 +1,55 @@
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace WebSocketRPC
+{
+ ///
+ /// WebSocket RPC middle-ware.
+ ///
+ public class WebSocketRPCMiddleware
+ {
+ private readonly RequestDelegate next;
+ private Action onConnection;
+
+ ///
+ /// Creates new web-socket RPC middle-ware.
+ ///
+ /// Next middle-ware in the pipeline.
+ /// Action triggered when a new connection is received.
+ public WebSocketRPCMiddleware(RequestDelegate next,
+ Action onConnection)
+ {
+ this.next = next;
+ this.onConnection = onConnection;
+ }
+
+ ///
+ /// Invokes the web-socket listener.
+ ///
+ /// HTTP context.
+ /// Listener task.
+ public async Task Invoke(HttpContext context)
+ {
+ if (!context.WebSockets.IsWebSocketRequest)
+ {
+ await next(context);
+ return;
+ }
+
+ var socket = await context.WebSockets.AcceptWebSocketAsync();
+
+ var connection = new Connection { Socket = socket, Cookies = null /*context.Request.Cookies*/ };
+ try
+ {
+ onConnection(context, connection);
+ await Connection.ListenReceiveAsync(connection, CancellationToken.None);
+ }
+ finally
+ {
+ socket?.Dispose();
+ }
+ }
+ }
+}
diff --git a/Source/WebSocketRPC.AspCore/WebSokcetRPCMiddlewareExtensions.cs b/Source/WebSocketRPC.AspCore/WebSokcetRPCMiddlewareExtensions.cs
new file mode 100644
index 0000000..1747665
--- /dev/null
+++ b/Source/WebSocketRPC.AspCore/WebSokcetRPCMiddlewareExtensions.cs
@@ -0,0 +1,37 @@
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Http;
+using System;
+
+namespace WebSocketRPC
+{
+ ///
+ /// WebSocket RPC middle-ware extensions.
+ ///
+ public static class WebSokcetRPCMiddlewareExtensions
+ {
+ ///
+ /// Branches the request pipeline based on matches of the given request path. If the request path starts with the given path, the branch is executed.
+ ///
+ /// Application builder.
+ /// The request path to match.
+ /// Action triggered when a new connection is established.
+ /// Application builder.
+ public static IApplicationBuilder MapWebSocketRPC(this IApplicationBuilder app,
+ PathString path,
+ Action onConnection)
+ {
+ return app.Map(path, (_app) => _app.UseMiddleware(onConnection));
+ }
+
+ ///
+ /// Adds a WebSocketRPC middleware to the application's request pipeline.
+ ///
+ ///
+ ///
+ /// Application builder.
+ public static IApplicationBuilder UseWebSocketRPC(this IApplicationBuilder app, Action onConnection)
+ {
+ return app.UseMiddleware(onConnection);
+ }
+ }
+}
diff --git a/Source/WebsocketRPC/ClientServer/Helper.cs b/Source/WebSocketRPC.Base/ClientServer/ArraySegmentExtensions.cs
similarity index 98%
rename from Source/WebsocketRPC/ClientServer/Helper.cs
rename to Source/WebSocketRPC.Base/ClientServer/ArraySegmentExtensions.cs
index 3368632..b6087e5 100644
--- a/Source/WebsocketRPC/ClientServer/Helper.cs
+++ b/Source/WebSocketRPC.Base/ClientServer/ArraySegmentExtensions.cs
@@ -26,7 +26,7 @@
using System;
using System.Text;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
///
/// Provides the helper methods.
diff --git a/Source/WebsocketRPC/ClientServer/Connection.cs b/Source/WebSocketRPC.Base/ClientServer/Connection.cs
similarity index 98%
rename from Source/WebsocketRPC/ClientServer/Connection.cs
rename to Source/WebSocketRPC.Base/ClientServer/Connection.cs
index 7b00d59..a543fcd 100644
--- a/Source/WebsocketRPC/ClientServer/Connection.cs
+++ b/Source/WebSocketRPC.Base/ClientServer/Connection.cs
@@ -31,7 +31,7 @@
using System.Threading;
using System.Threading.Tasks;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
///
/// Represents the websocket connection.
@@ -48,7 +48,7 @@ public class Connection
///
/// Gets the cookie collection.
///
- public CookieCollection Cookies { get; internal set; }
+ public CookieCollection Cookies { get; internal set; }
///
/// Message receive event. Args: message, is text message.
diff --git a/Source/WebSocketRPC.Base/ConnectionBinders/Base/Binder.cs b/Source/WebSocketRPC.Base/ConnectionBinders/Base/Binder.cs
new file mode 100644
index 0000000..6f64eca
--- /dev/null
+++ b/Source/WebSocketRPC.Base/ConnectionBinders/Base/Binder.cs
@@ -0,0 +1,62 @@
+#region License
+// Copyright © 2017 Darko Jurić
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+#endregion
+
+using System;
+using System.Diagnostics;
+
+
+namespace WebSocketRPC
+{
+ abstract class Binder : IBinder
+ {
+ public Connection Connection { get; private set; }
+
+ protected Binder(Connection connection)
+ {
+ Connection = connection;
+
+ Connection.OnOpen += () =>
+ {
+ Debug.WriteLine("Open");
+
+ RPC.AllBinders.Add(this);
+ };
+
+ Connection.OnClose += () =>
+ {
+ Debug.WriteLine("Close");
+
+ RPC.AllBinders.Remove(this);
+ };
+
+ Connection.OnError += e =>
+ {
+ Debug.WriteLine("Error");
+
+ RPC.AllBinders.Remove(this);
+ };
+ }
+ }
+}
diff --git a/Source/WebSocketRPC.Base/ConnectionBinders/Base/IBinder.cs b/Source/WebSocketRPC.Base/ConnectionBinders/Base/IBinder.cs
new file mode 100644
index 0000000..f9b2051
--- /dev/null
+++ b/Source/WebSocketRPC.Base/ConnectionBinders/Base/IBinder.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Linq.Expressions;
+using System.Threading.Tasks;
+
+namespace WebSocketRPC
+{
+ ///
+ /// The base binder interface.
+ ///
+ public interface IBinder
+ {
+ ///
+ /// Gets the associated connection.
+ ///
+ Connection Connection { get; }
+ }
+
+ ///
+ /// Local binder interface for the specified object type.
+ ///
+ /// Object type.
+ public interface ILocalBinder : IBinder
+ {
+ ///
+ /// Gets the associated object.
+ ///
+ T Object { get; }
+ }
+
+ ///
+ /// Remote binder interface for the specified interface type.
+ ///
+ /// Interface type.
+ public interface IRemoteBinder : IBinder
+ {
+ ///
+ /// Calls the RPC method.
+ ///
+ /// Method getter.
+ /// RPC invoking task.
+ Task CallAsync(Expression> functionExpression);
+
+ ///
+ /// Calls the RPC method.
+ ///
+ /// Result.
+ /// Method getter.
+ /// RPC result.
+ Task CallAsync(Expression> functionExpression);
+
+
+ ///
+ /// Calls the RPC method.
+ ///
+ /// Method getter.
+ /// RPC task result.
+ Task CallAsync(Expression> functionExpression);
+
+ ///
+ /// Calls the RPC method.
+ ///
+ /// Result.
+ /// Method getter.
+ /// RPC result.
+ Task CallAsync(Expression>> functionExpression);
+ }
+}
diff --git a/Source/WebsocketRPC/ConnectionBinders/LocalBinder.cs b/Source/WebSocketRPC.Base/ConnectionBinders/LocalBinder.cs
similarity index 94%
rename from Source/WebsocketRPC/ConnectionBinders/LocalBinder.cs
rename to Source/WebSocketRPC.Base/ConnectionBinders/LocalBinder.cs
index 99b2de7..91e73af 100644
--- a/Source/WebsocketRPC/ConnectionBinders/LocalBinder.cs
+++ b/Source/WebSocketRPC.Base/ConnectionBinders/LocalBinder.cs
@@ -24,11 +24,11 @@
#endregion
using System;
-using static WebsocketRPC.RPCSettings;
+using static WebSocketRPC.RPCSettings;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
- class LocalBinder : BinderBase, ILocalBinder
+ class LocalBinder : Binder, ILocalBinder
{
LocalInvoker lInvoker = null;
diff --git a/Source/WebsocketRPC/ConnectionBinders/Binder.cs b/Source/WebSocketRPC.Base/ConnectionBinders/LocalRemoteBinder.cs
similarity index 93%
rename from Source/WebsocketRPC/ConnectionBinders/Binder.cs
rename to Source/WebSocketRPC.Base/ConnectionBinders/LocalRemoteBinder.cs
index 4c77818..40414bc 100644
--- a/Source/WebsocketRPC/ConnectionBinders/Binder.cs
+++ b/Source/WebSocketRPC.Base/ConnectionBinders/LocalRemoteBinder.cs
@@ -26,16 +26,16 @@
using System;
using System.Linq.Expressions;
using System.Threading.Tasks;
-using static WebsocketRPC.RPCSettings;
+using static WebSocketRPC.RPCSettings;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
- class Binder : BinderBase, ILocalBinder, IRemoteBinder
+ class LocalRemoteBinder : Binder, ILocalBinder, IRemoteBinder
{
LocalInvoker lInvoker = null;
RemoteInvoker rInvoker = null;
- public Binder(Connection connection, TObj obj)
+ public LocalRemoteBinder(Connection connection, TObj obj)
: base(connection)
{
lInvoker = new LocalInvoker();
diff --git a/Source/WebsocketRPC/ConnectionBinders/RemoteBinder.cs b/Source/WebSocketRPC.Base/ConnectionBinders/RemoteBinder.cs
similarity index 95%
rename from Source/WebsocketRPC/ConnectionBinders/RemoteBinder.cs
rename to Source/WebSocketRPC.Base/ConnectionBinders/RemoteBinder.cs
index 768957d..d551549 100644
--- a/Source/WebsocketRPC/ConnectionBinders/RemoteBinder.cs
+++ b/Source/WebSocketRPC.Base/ConnectionBinders/RemoteBinder.cs
@@ -26,11 +26,11 @@
using System;
using System.Linq.Expressions;
using System.Threading.Tasks;
-using static WebsocketRPC.RPCSettings;
+using static WebSocketRPC.RPCSettings;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
- class RemoteBinder : BinderBase, IRemoteBinder
+ class RemoteBinder : Binder, IRemoteBinder
{
RemoteInvoker rInvoker = null;
diff --git a/Source/WebsocketRPC/Invokers/LocalInvoker.cs b/Source/WebSocketRPC.Base/Invokers/LocalInvoker.cs
similarity index 99%
rename from Source/WebsocketRPC/Invokers/LocalInvoker.cs
rename to Source/WebSocketRPC.Base/Invokers/LocalInvoker.cs
index 117c6c1..dad67e5 100644
--- a/Source/WebsocketRPC/Invokers/LocalInvoker.cs
+++ b/Source/WebSocketRPC.Base/Invokers/LocalInvoker.cs
@@ -27,12 +27,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-using Newtonsoft.Json.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using NameInfoPairs = System.Collections.Generic.Dictionary;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
class LocalInvoker
{
diff --git a/Source/WebsocketRPC/Invokers/Messages.cs b/Source/WebSocketRPC.Base/Invokers/Messages.cs
similarity index 99%
rename from Source/WebsocketRPC/Invokers/Messages.cs
rename to Source/WebSocketRPC.Base/Invokers/Messages.cs
index 2d6a53f..6e28a5b 100644
--- a/Source/WebsocketRPC/Invokers/Messages.cs
+++ b/Source/WebSocketRPC.Base/Invokers/Messages.cs
@@ -27,7 +27,7 @@
using Newtonsoft.Json.Linq;
using System.Linq;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
struct Request
{
diff --git a/Source/WebsocketRPC/Invokers/RemoteInvoker.cs b/Source/WebSocketRPC.Base/Invokers/RemoteInvoker.cs
similarity index 99%
rename from Source/WebsocketRPC/Invokers/RemoteInvoker.cs
rename to Source/WebSocketRPC.Base/Invokers/RemoteInvoker.cs
index d4f4236..ad4e465 100644
--- a/Source/WebsocketRPC/Invokers/RemoteInvoker.cs
+++ b/Source/WebSocketRPC.Base/Invokers/RemoteInvoker.cs
@@ -31,7 +31,7 @@
using System.Linq.Expressions;
using System.Reflection;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
class RemoteInvoker
{
diff --git a/Source/WebsocketRPC/RPC.cs b/Source/WebSocketRPC.Base/RPC.cs
similarity index 97%
rename from Source/WebsocketRPC/RPC.cs
rename to Source/WebSocketRPC.Base/RPC.cs
index c691ea5..64ac2ef 100644
--- a/Source/WebsocketRPC/RPC.cs
+++ b/Source/WebSocketRPC.Base/RPC.cs
@@ -30,7 +30,7 @@
using System.Text;
using System.Threading.Tasks;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
///
/// Provides methods for invoking the RPC.
@@ -40,7 +40,7 @@ public static class RPC
///
/// Gets the all binders.
///
- public static readonly List AllBinders = new List();
+ internal static readonly List AllBinders = new List();
///
/// Creates two-way RPC receiving-sending binding for the provided connection.
@@ -51,8 +51,8 @@ public static class RPC
/// Object to bind to.
/// Binder.
public static IBinder Bind(this Connection connection, TObj obj)
- {
- return new Binder(connection, obj);
+ {
+ return new LocalRemoteBinder(connection, obj);
}
///
@@ -118,7 +118,7 @@ public static IEnumerable> For(object obj)
///
/// Received data.
/// True if the data contain RPC message, false otherwise.
- public static bool IsRPC(this ArraySegment data)
+ public static bool IsRpcMessage(this ArraySegment data)
{
var str = data.ToString(Encoding.ASCII);
return !Request.FromJson(str).IsEmpty || !Response.FromJson(str).IsEmpty;
diff --git a/Source/WebsocketRPC/RPCSettings.cs b/Source/WebSocketRPC.Base/RPCSettings.cs
similarity index 99%
rename from Source/WebsocketRPC/RPCSettings.cs
rename to Source/WebSocketRPC.Base/RPCSettings.cs
index cc5b644..26a7857 100644
--- a/Source/WebsocketRPC/RPCSettings.cs
+++ b/Source/WebSocketRPC.Base/RPCSettings.cs
@@ -28,7 +28,7 @@
using System;
using System.Text;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
///
/// RPC settings.
diff --git a/Source/WebSocketRPC.Base/WebSocketRPC.Base.projitems b/Source/WebSocketRPC.Base/WebSocketRPC.Base.projitems
new file mode 100644
index 0000000..96b9770
--- /dev/null
+++ b/Source/WebSocketRPC.Base/WebSocketRPC.Base.projitems
@@ -0,0 +1,25 @@
+
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+ true
+ eaebaa06-d5bb-4106-8694-c022832175d6
+
+
+ WebSocketRPC.Base
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Source/WebSocketRPC.Base/WebSocketRPC.Base.shproj b/Source/WebSocketRPC.Base/WebSocketRPC.Base.shproj
new file mode 100644
index 0000000..e6246f9
--- /dev/null
+++ b/Source/WebSocketRPC.Base/WebSocketRPC.Base.shproj
@@ -0,0 +1,13 @@
+
+
+
+ eaebaa06-d5bb-4106-8694-c022832175d6
+ 14.0
+
+
+
+
+
+
+
+
diff --git a/Source/WebSocketRPC.JS/ClientAPIBase.cs b/Source/WebSocketRPC.JS/ClientAPIBase.cs
deleted file mode 100644
index 7ccfb71..0000000
--- a/Source/WebSocketRPC.JS/ClientAPIBase.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.IO;
-using Microsoft.Azure.WebJobs;
-using Microsoft.Azure.WebJobs.Host;
-
-namespace WebSocketRPC.JS
-{
- public static class ClientAPIBase
- {
- [FunctionName("ClientAPIBase")]
- public static void Run([BlobTrigger("samples-workitems/{name}", Connection = "")]Stream myBlob, string name, TraceWriter log)
- {
- log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
- }
- }
-}
diff --git a/Source/WebSocketRPC.JS/Components/JsCallerGenerator.cs b/Source/WebSocketRPC.JS/Components/JsCallerGenerator.cs
index 297bc6b..6279221 100644
--- a/Source/WebSocketRPC.JS/Components/JsCallerGenerator.cs
+++ b/Source/WebSocketRPC.JS/Components/JsCallerGenerator.cs
@@ -31,7 +31,7 @@
using System.Reflection;
using System.Text;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
static class JsCallerGenerator
{
@@ -80,7 +80,7 @@ public static string GenerateHeader(string className)
//API base
var assembly = Assembly.GetExecutingAssembly();
- var resourceName = assembly.GetName().Name + "." + "ClientAPIBase.js";
+ var resourceName = assembly.GetManifestResourceNames().First(x => x.Contains("ClientAPIBase.js"));
var lines = new List();
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
diff --git a/Source/WebSocketRPC.JS/Components/JsDocGenerator.cs b/Source/WebSocketRPC.JS/Components/JsDocGenerator.cs
index 9b54814..8f4ddc1 100644
--- a/Source/WebSocketRPC.JS/Components/JsDocGenerator.cs
+++ b/Source/WebSocketRPC.JS/Components/JsDocGenerator.cs
@@ -29,7 +29,7 @@
using System.Text;
using System.Xml;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
static class JsDocGenerator
{
diff --git a/Source/WebSocketRPC.JS/RPCJs.cs b/Source/WebSocketRPC.JS/RPCJs.cs
index 90b72cf..e85bb56 100644
--- a/Source/WebSocketRPC.JS/RPCJs.cs
+++ b/Source/WebSocketRPC.JS/RPCJs.cs
@@ -30,7 +30,7 @@
using System.Reflection;
using System.Text;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
///
/// Contains function related to Javascript RPC.
diff --git a/Source/WebSocketRPC.JS/ClientAPIBase.js b/Source/WebSocketRPC.JS/Resources/ClientAPIBase.js
similarity index 98%
rename from Source/WebSocketRPC.JS/ClientAPIBase.js
rename to Source/WebSocketRPC.JS/Resources/ClientAPIBase.js
index 73e1c41..4aab0af 100644
--- a/Source/WebSocketRPC.JS/ClientAPIBase.js
+++ b/Source/WebSocketRPC.JS/Resources/ClientAPIBase.js
@@ -63,7 +63,7 @@ function onMessage(msg, onError)
var data = null;
try { data = JSON.parse(msg.data); } catch (e) { }
- var isRPCResponse = (data !== null) && !!registeredFunctions[data.FunctionName] && (!!data.ReturnValue || !!data.Error);
+ var isRPCResponse = (data !== null) && !!registeredFunctions[data.FunctionName] && (data.ReturnValue !== undefined || !!data.Error);
var isCallRequest = (data !== null) && !!data.Arguments;
if (isRPCResponse)
diff --git a/Source/WebSocketRPC.JS/WebSocketRPC.JS.csproj b/Source/WebSocketRPC.JS/WebSocketRPC.JS.csproj
index 94d8a4a..954dc88 100644
--- a/Source/WebSocketRPC.JS/WebSocketRPC.JS.csproj
+++ b/Source/WebSocketRPC.JS/WebSocketRPC.JS.csproj
@@ -1,50 +1,36 @@
-
-
-
-
- Debug
- AnyCPU
- {965791BF-8F77-4A69-97E2-8B6B66CF9863}
- Library
- Properties
- WebSocketRPC.JS
- WebSocketRPC.JS
- v4.7
- 512
-
+
+
+ netcoreapp2.0;net47
+
+
+
+ bin\
-
- true
- full
- false
- bin\
- DEBUG;TRACE
- prompt
- 4
+
+
+
+
+
+
+ bin\$(TargetFramework)\WebsocketRPC.JS.xml
+ true
-
- pdbonly
- true
- bin\
- TRACE
- prompt
- 4
- bin\WebSocketRPC.JS.xml
+
+
+
+ Darko Jurić
+ Generates the Javascript code for websocket-connection using the provided .NET interface.
+ Darko Jurić
+ https://raw.githubusercontent.com/dajuric/websocket-rpc/master/LICENSE.md
+ https://raw.githubusercontent.com/dajuric/websocket-rpc/master/Deploy/Logo/Logo-small.png
+ https://github.com/dajuric/websocket-rpc/
+ https://github.com/dajuric/websocket-rpc/
+ websocket; websocket-client; Javascript; RPC; C#; .NET
+ true
+
+ 1.0.0
+ ../../Deploy/Nuget/bin/
+ WebSocketRPC
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/Source/WebsocketRPC/ClientServer/Client.cs b/Source/WebsocketRPC/ClientServer/Client.cs
index 4d4a47c..950d0be 100644
--- a/Source/WebsocketRPC/ClientServer/Client.cs
+++ b/Source/WebsocketRPC/ClientServer/Client.cs
@@ -28,7 +28,7 @@
using System.Threading;
using System.Threading.Tasks;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
///
/// Websocket client.
diff --git a/Source/WebsocketRPC/ClientServer/Server.cs b/Source/WebsocketRPC/ClientServer/Server.cs
index c0dfcb1..3ae5f59 100644
--- a/Source/WebsocketRPC/ClientServer/Server.cs
+++ b/Source/WebsocketRPC/ClientServer/Server.cs
@@ -29,7 +29,7 @@
using System.Threading;
using System.Threading.Tasks;
-namespace WebsocketRPC
+namespace WebSocketRPC
{
///
/// Websocket server.
@@ -55,7 +55,7 @@ public static async Task ListenAsync(string httpListenerPrefix, CancellationToke
if (listenerContext.Request.IsWebSocketRequest)
{
- ListenAsync(listenerContext, token, onConnection).Wait(0);
+ listenAsync(listenerContext, token, onConnection).Wait(0);
}
else
{
@@ -70,15 +70,7 @@ public static async Task ListenAsync(string httpListenerPrefix, CancellationToke
listener.Stop();
}
- ///
- /// Creates and starts a new listening websocket from the provided http listener context.
- /// In case of the invalid http request / websocket creation error, the http connection is closed.
- ///
- /// Http listener context.
- /// Cancellation token.
- /// Action executed when connection is created.
- /// Websocket listener task.
- public static async Task ListenAsync(HttpListenerContext listenerContext, CancellationToken token, Action onConnection)
+ static async Task listenAsync(HttpListenerContext listenerContext, CancellationToken token, Action onConnection)
{
if (!listenerContext.Request.IsWebSocketRequest)
return;
diff --git a/Source/WebsocketRPC/ConnectionBinders/BinderBase.cs b/Source/WebsocketRPC/ConnectionBinders/BinderBase.cs
deleted file mode 100644
index d330018..0000000
--- a/Source/WebsocketRPC/ConnectionBinders/BinderBase.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-#region License
-// Copyright © 2017 Darko Jurić
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-#endregion
-
-using System;
-using System.Diagnostics;
-using System.Linq.Expressions;
-using System.Threading.Tasks;
-
-namespace WebsocketRPC
-{
- ///
- /// The base binder interface.
- ///
- public interface IBinder
- {
- ///
- /// Gets the associated connection.
- ///
- Connection Connection { get; }
- }
-
- ///
- /// Local binder interface for the specified object type.
- ///
- /// Object type.
- public interface ILocalBinder : IBinder
- {
- ///
- /// Gets the associated object.
- ///
- T Object { get; }
- }
-
- ///
- /// Remote binder interface for the specified interface type.
- ///
- /// Interface type.
- public interface IRemoteBinder : IBinder
- {
- ///
- /// Calls the RPC method.
- ///
- /// Method getter.
- /// RPC invoking task.
- Task CallAsync(Expression> functionExpression);
-
- ///
- /// Calls the RPC method.
- ///
- /// Result.
- /// Method getter.
- /// RPC result.
- Task CallAsync(Expression> functionExpression);
-
-
- ///
- /// Calls the RPC method.
- ///
- /// Method getter.
- /// RPC task result.
- Task CallAsync(Expression> functionExpression);
-
- ///
- /// Calls the RPC method.
- ///
- /// Result.
- /// Method getter.
- /// RPC result.
- Task CallAsync(Expression>> functionExpression);
- }
-
- ///
- /// Relay connection binder for the specified interface type.
- ///
- /// Interface type.
- public interface IRelayBinder : IBinder
- { }
-
- abstract class BinderBase : IBinder
- {
- public Connection Connection { get; private set; }
-
- protected BinderBase(Connection connection)
- {
- Connection = connection;
-
- Connection.OnOpen += () =>
- {
- Debug.WriteLine("Open");
-
- RPC.AllBinders.Add(this);
- };
-
- Connection.OnClose += () =>
- {
- Debug.WriteLine("Close");
-
- RPC.AllBinders.Remove(this);
- };
-
- Connection.OnError += e =>
- {
- Debug.WriteLine("Error");
-
- RPC.AllBinders.Remove(this);
- };
- }
- }
-}
diff --git a/Source/WebsocketRPC/WebsocketRPC.csproj b/Source/WebsocketRPC/WebsocketRPC.csproj
index 16fd303..fca108e 100644
--- a/Source/WebsocketRPC/WebsocketRPC.csproj
+++ b/Source/WebsocketRPC/WebsocketRPC.csproj
@@ -1,63 +1,37 @@
-
-
-
+
+
+ netcoreapp2.0;net47
+
+
- Debug
- AnyCPU
- {AB4A5DDF-1F91-4AF8-9E9C-242832576C5E}
- Library
- Properties
- WebsocketRPC
- WebsocketRPC
- v4.7
- 512
-
-
-
- true
- full
- false
- bin\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
bin\
- TRACE
- prompt
- 4
- bin\WebsocketRPC.xml
-
-
- ..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
\ No newline at end of file
+
+
+ bin\$(TargetFramework)\WebsocketRPC.xml
+ true
+
+
+
+
+ Darko Jurić
+ Provides full duplex RPC over websocket.
+ Darko Jurić
+ https://raw.githubusercontent.com/dajuric/websocket-rpc/master/LICENSE.md
+ https://raw.githubusercontent.com/dajuric/websocket-rpc/master/Deploy/Logo/Logo-small.png
+ https://github.com/dajuric/websocket-rpc/
+ https://github.com/dajuric/websocket-rpc/
+ websocket; websocket-client; websocket-server; RPC; C#; .NET
+ true
+
+ 1.0.0
+ ../../Deploy/Nuget/bin/
+
+
+
+
diff --git a/Source/WebsocketRPC/packages.config b/Source/WebsocketRPC/packages.config
deleted file mode 100644
index e157ba1..0000000
--- a/Source/WebsocketRPC/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/WebsocketRPC.sln b/WebsocketRPC.sln
index 2238d3c..6ea6abf 100644
--- a/WebsocketRPC.sln
+++ b/WebsocketRPC.sln
@@ -50,18 +50,19 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Logo", "Logo", "{6E575BA8-2
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{CBCEF1A5-1044-49DB-8A19-2443FFBE3DFE}"
ProjectSection(SolutionItems) = preProject
- Deploy\Nuget\Build.cmd = Deploy\Nuget\Build.cmd
Deploy\Nuget\Push.cmd = Deploy\Nuget\Push.cmd
- Deploy\Nuget\UpdateNuGet.cmd = Deploy\Nuget\UpdateNuGet.cmd
EndProjectSection
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuSpecs", "nuSpecs", "{07BE9233-A701-4899-8FB0-21D8EE0057D3}"
- ProjectSection(SolutionItems) = preProject
- Deploy\Nuget\nuSpecs\WebsocketRPC.JS.nuspec = Deploy\Nuget\nuSpecs\WebsocketRPC.JS.nuspec
- Deploy\Nuget\nuSpecs\WebsocketRPC.nuspec = Deploy\Nuget\nuSpecs\WebsocketRPC.nuspec
- EndProjectSection
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "WebSocketRPC.Base", "Source\WebSocketRPC.Base\WebSocketRPC.Base.shproj", "{EAEBAA06-D5BB-4106-8694-C022832175D6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebSocketRPC.AspCore", "Source\WebSocketRPC.AspCore\WebSocketRPC.AspCore.csproj", "{CE4BAD88-2358-4B3D-8A34-90A74C73E521}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspRpc", "Samples\AspRpc\AspRpc.csproj", "{CFC334A5-2B52-42A0-87AE-4B3F84B09530}"
EndProject
Global
+ GlobalSection(SharedMSBuildProjectFiles) = preSolution
+ Source\WebSocketRPC.Base\WebSocketRPC.Base.projitems*{eaebaa06-d5bb-4106-8694-c022832175d6}*SharedItemsImports = 13
+ EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
@@ -95,6 +96,14 @@ Global
{9F82F6DD-238B-4F65-A95C-55F2BA20F1B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F82F6DD-238B-4F65-A95C-55F2BA20F1B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F82F6DD-238B-4F65-A95C-55F2BA20F1B0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CE4BAD88-2358-4B3D-8A34-90A74C73E521}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CE4BAD88-2358-4B3D-8A34-90A74C73E521}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CE4BAD88-2358-4B3D-8A34-90A74C73E521}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CE4BAD88-2358-4B3D-8A34-90A74C73E521}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CFC334A5-2B52-42A0-87AE-4B3F84B09530}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CFC334A5-2B52-42A0-87AE-4B3F84B09530}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CFC334A5-2B52-42A0-87AE-4B3F84B09530}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CFC334A5-2B52-42A0-87AE-4B3F84B09530}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -110,7 +119,9 @@ Global
{9F82F6DD-238B-4F65-A95C-55F2BA20F1B0} = {E5509F73-1E5E-45B4-AED7-4A38F8DF1DDE}
{6E575BA8-2787-4A5D-9742-8ACBA07C93D9} = {B998D2DB-7CA7-4A1B-8B98-801973A12D20}
{CBCEF1A5-1044-49DB-8A19-2443FFBE3DFE} = {B998D2DB-7CA7-4A1B-8B98-801973A12D20}
- {07BE9233-A701-4899-8FB0-21D8EE0057D3} = {CBCEF1A5-1044-49DB-8A19-2443FFBE3DFE}
+ {EAEBAA06-D5BB-4106-8694-C022832175D6} = {3CE373E0-6D9A-48C4-808D-510E6FB69D5C}
+ {CE4BAD88-2358-4B3D-8A34-90A74C73E521} = {3CE373E0-6D9A-48C4-808D-510E6FB69D5C}
+ {CFC334A5-2B52-42A0-87AE-4B3F84B09530} = {E5509F73-1E5E-45B4-AED7-4A38F8DF1DDE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {591A6475-8DF2-42DA-AFF1-8EF88BCF6EE4}