diff --git a/README.md b/README.md
index f0ac2d1..a8dd5fe 100644
--- a/README.md
+++ b/README.md
@@ -11,9 +11,7 @@
**WebSokcetRPC** - RPC over websocket for .NET
Lightweight .NET framework for making RPC over websockets. Supports full duplex connections; .NET or Javascript clients.
-
+ > **Tutorial:** CodeProject article
## Why WebSocketRPC ?
@@ -193,13 +191,6 @@ api.connect(async () =>
{empty} .
-
-## Getting started
-+ Samples
-
-
## How to Engage, Contribute and Provide Feedback
Remember: Your opinion is important and will define the future roadmap.
+ questions, comments - Github
diff --git a/Samples/ClientJs/Program.cs b/Samples/ClientJs/Program.cs
index fd3d55d..53fe065 100644
--- a/Samples/ClientJs/Program.cs
+++ b/Samples/ClientJs/Program.cs
@@ -9,9 +9,9 @@
namespace ClientJs
{
///
- /// Remote API.
+ /// Progress API.
///
- interface IRemoteAPI
+ interface IProgressAPI
{
///
/// Writes progress.
@@ -21,9 +21,9 @@ interface IRemoteAPI
}
///
- /// Local API.
+ /// Task API.
///
- class LocalAPI
+ class TaskAPI
{
///
/// Executes long running addition task.
@@ -36,7 +36,7 @@ public async Task LongRunningTask(int a, int b)
for (var p = 0; p <= 100; p += 5)
{
await Task.Delay(250);
- await RPC.For(this).CallAsync(x => x.WriteProgress((float)p / 100));
+ await RPC.For(this).CallAsync(x => x.WriteProgress((float)p / 100));
}
return a + b;
@@ -50,13 +50,13 @@ class Program
static void Main(string[] args)
{
//generate js code
- File.WriteAllText($"./Site/{nameof(LocalAPI)}.js", RPCJs.GenerateCallerWithDoc());
+ File.WriteAllText($"./Site/{nameof(TaskAPI)}.js", RPCJs.GenerateCallerWithDoc());
//start server and bind its local and remote API
var cts = new CancellationTokenSource();
var t = Server.ListenAsync("http://localhost:8001/", cts.Token, (c, ws) =>
{
- c.Bind(new LocalAPI());
+ c.Bind(new TaskAPI());
c.BindTimeout(TimeSpan.FromSeconds(1)); //close connection if there is no incommming message after X seconds
});
diff --git a/Samples/ClientJs/Site/Index.html b/Samples/ClientJs/Site/Index.html
index 8b657be..574b485 100644
--- a/Samples/ClientJs/Site/Index.html
+++ b/Samples/ClientJs/Site/Index.html
@@ -1,7 +1,7 @@
Client JS
-
+
@@ -21,7 +21,7 @@
}
//init API
- var api = new LocalAPI("ws://localhost:8001");
+ var api = new TaskAPI("ws://localhost:8001");
//implement the interface
api.writeProgress = p =>
diff --git a/Samples/ServerClientSample/Client/Program.cs b/Samples/ServerClientSample/Client/Program.cs
index 10188f2..066de1c 100644
--- a/Samples/ServerClientSample/Client/Program.cs
+++ b/Samples/ServerClientSample/Client/Program.cs
@@ -7,12 +7,12 @@
namespace TestClient
{
- interface ILocalAPI
+ interface ITaskAPI
{
Task LongRunningTask(int a, int b);
}
- class RemoteAPI //:IRemoteAPI
+ class ProgressAPI //:ITaskAPI
{
public void WriteProgress(float progress)
{
@@ -34,10 +34,10 @@ static void Main(string[] args)
var cts = new CancellationTokenSource();
var t = Client.ConnectAsync("ws://localhost:8001/", cts.Token, c =>
{
- c.Bind(new RemoteAPI());
+ c.Bind(new ProgressAPI());
c.OnOpen += async () =>
{
- var r = await RPC.For().CallAsync(x => x.LongRunningTask(5, 3));
+ var r = await RPC.For().CallAsync(x => x.LongRunningTask(5, 3));
Console.WriteLine("\nResult: " + r.First());
};
},
diff --git a/Samples/ServerClientSample/Server/Program.cs b/Samples/ServerClientSample/Server/Program.cs
index 1ca563a..c735f72 100644
--- a/Samples/ServerClientSample/Server/Program.cs
+++ b/Samples/ServerClientSample/Server/Program.cs
@@ -7,19 +7,19 @@
namespace TestServer
{
- interface IRemoteAPI
+ interface IProgressAPI
{
void WriteProgress(float progress);
}
- class LocalAPI
+ class TaskAPI
{
public async Task LongRunningTask(int a, int b)
{
for (var p = 0; p <= 100; p += 5)
{
await Task.Delay(250);
- await RPC.For(this).CallAsync(x => x.WriteProgress((float)p / 100));
+ await RPC.For(this).CallAsync(x => x.WriteProgress((float)p / 100));
}
return a + b;
@@ -38,7 +38,7 @@ static void Main(string[] args)
var cts = new CancellationTokenSource();
var t = Server.ListenAsync("http://localhost:8001/", cts.Token, (c, wc) =>
{
- c.Bind(new LocalAPI());
+ c.Bind(new TaskAPI());
c.OnOpen += () => Task.Run((Action)writeClientCount);
c.OnClose += (s, d) => Task.Run((Action)writeClientCount);
@@ -50,7 +50,7 @@ static void Main(string[] args)
static void writeClientCount()
{
- var cc = RPC.For().Count();
+ var cc = RPC.For().Count();
Console.WriteLine("Client count: " + cc);
}
}
diff --git a/Source/WebSocketRPC.JS/ClassDiagram1.cd b/Source/WebSocketRPC.JS/ClassDiagram1.cd
deleted file mode 100644
index 7b89419..0000000
--- a/Source/WebSocketRPC.JS/ClassDiagram1.cd
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/Source/WebSocketRPC.JS/Components/JsDocGenerator.cs b/Source/WebSocketRPC.JS/Components/JsDocGenerator.cs
index 83e5c1a..d322e06 100644
--- a/Source/WebSocketRPC.JS/Components/JsDocGenerator.cs
+++ b/Source/WebSocketRPC.JS/Components/JsDocGenerator.cs
@@ -26,7 +26,9 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Text;
+using System.Threading.Tasks;
using System.Xml;
namespace WebSocketRPC
@@ -97,7 +99,7 @@ public static string GetMethodDoc(XmlNodeList mmebers, string methodName,
jsDoc.AppendLine(String.Format("{0} * @param {{{1}}} - {2}", linePrefix, pTypes[i].Name, p[pNames[i]]));
}
- jsDoc.AppendLine(String.Format("{0} * @returns {{{1}}} - {2}", linePrefix, returnType.Name, r));
+ jsDoc.AppendLine(String.Format("{0} * @returns {{{1}}} - {2}", linePrefix, getTypeName(returnType), r));
}
jsDoc.AppendLine(String.Format("{0}*/", linePrefix));
@@ -171,5 +173,13 @@ static string getReturn(XmlNode node)
return s;
}
+
+ static string getTypeName(Type type)
+ {
+ if (type.GetGenericTypeDefinition() != typeof(Task<>))
+ return type.Name;
+
+ return type.GenericTypeArguments.First().Name + " (Task)";
+ }
}
}
diff --git a/Source/WebSocketRPC.JS/Resources/ClientAPIBase.js b/Source/WebSocketRPC.JS/Resources/ClientAPIBase.js
index e9d3dc5..b5b0253 100644
--- a/Source/WebSocketRPC.JS/Resources/ClientAPIBase.js
+++ b/Source/WebSocketRPC.JS/Resources/ClientAPIBase.js
@@ -153,14 +153,14 @@ this.onOtherMessage = null;
* Send the message using the underlying websocket connection.
* @param {Message} - message.
*/
-this.send = (msg) => ws.send(msg);
+this.send = function (message) { ws.send(message); }
/*
* Closes the underlying websocket connection.
* @param {number} - Status code (see https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes for details).
* @param {string} - Human readable close reason (the max length is 123 bytes / ASCII characters).
*/
-this.close = (code, closeReason) =>
+this.close = function (code, closeReason)
{
code = (code === undefined) ? 1000 : code;
closeReason = closeReason || "";
diff --git a/Tests/Program.cs b/Tests/Program.cs
index bbd1ca7..9efeff9 100644
--- a/Tests/Program.cs
+++ b/Tests/Program.cs
@@ -41,13 +41,13 @@ static void Main(string[] args)
//RunTest(TestConnectionException);
//RunTest(TestRpcInitializeException);
- //RunTest(TestRpcUnhandledException);
+ RunTest(TestRpcUnhandledException);
//RunTest(TestRpcHandledException);
//RunTest(TestMaxMessageSize);
//RunTest(TestTimeout);
- RunTest(TestRpcTimeout);
+ //RunTest(TestRpcTimeout);
//RunTest(TestMultiClient);