diff --git a/JsonRPC.sln b/JsonRPC.sln new file mode 100644 index 0000000..bc0d713 --- /dev/null +++ b/JsonRPC.sln @@ -0,0 +1,42 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{ECEBC2A1-9382-44B5-94A6-305DC8235859}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharp", "templates\CSharp\CSharp.csproj", "{16231421-DB23-46D0-AFA8-81099E3CF97A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{B6AB75C7-58FC-4F62-AFAA-ED8FEEBF2E1C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CSharp", "CSharp", "{833192BE-67E8-425F-9AA7-23532485682A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharp_Example", "examples\CSharp\Example\CSharp_Example.csproj", "{3BD8D8BF-46ED-4F52-BD78-8B22FF3A77A2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {16231421-DB23-46D0-AFA8-81099E3CF97A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {16231421-DB23-46D0-AFA8-81099E3CF97A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {16231421-DB23-46D0-AFA8-81099E3CF97A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {16231421-DB23-46D0-AFA8-81099E3CF97A}.Release|Any CPU.Build.0 = Release|Any CPU + {3BD8D8BF-46ED-4F52-BD78-8B22FF3A77A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3BD8D8BF-46ED-4F52-BD78-8B22FF3A77A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3BD8D8BF-46ED-4F52-BD78-8B22FF3A77A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3BD8D8BF-46ED-4F52-BD78-8B22FF3A77A2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {16231421-DB23-46D0-AFA8-81099E3CF97A} = {ECEBC2A1-9382-44B5-94A6-305DC8235859} + {833192BE-67E8-425F-9AA7-23532485682A} = {B6AB75C7-58FC-4F62-AFAA-ED8FEEBF2E1C} + {3BD8D8BF-46ED-4F52-BD78-8B22FF3A77A2} = {833192BE-67E8-425F-9AA7-23532485682A} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ED59162F-B7E7-4EA2-91D4-7F6D1BFBB820} + EndGlobalSection +EndGlobal diff --git a/examples/CSharp/Example/CSharp_Example.csproj b/examples/CSharp/Example/CSharp_Example.csproj index bab5dbb..724c9bc 100644 --- a/examples/CSharp/Example/CSharp_Example.csproj +++ b/examples/CSharp/Example/CSharp_Example.csproj @@ -6,7 +6,7 @@ Exe - net6.0 + net8.0 enable enable diff --git a/package.json b/package.json index b87d366..d40174b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hibas123/jrpcgen", - "version": "1.2.17", + "version": "1.2.18", "main": "lib/index.js", "license": "MIT", "packageManager": "yarn@3.1.1", @@ -48,4 +48,4 @@ "dependencies": { "fs-extra": "^10.0.0" } -} \ No newline at end of file +} diff --git a/packages-microsoft-prod.deb b/packages-microsoft-prod.deb new file mode 100644 index 0000000..bdb822a Binary files /dev/null and b/packages-microsoft-prod.deb differ diff --git a/templates/CSharp/CSharp.csproj b/templates/CSharp/CSharp.csproj index bafd05b..6afe43a 100644 --- a/templates/CSharp/CSharp.csproj +++ b/templates/CSharp/CSharp.csproj @@ -1,9 +1,10 @@ - - - - net6.0 - enable - enable - - - + + + + net6.0 + enable + enable + 10.0 + + + diff --git a/templates/CSharp/JRpcClient.cs b/templates/CSharp/JRpcClient.cs index 502be4b..444851e 100644 --- a/templates/CSharp/JRpcClient.cs +++ b/templates/CSharp/JRpcClient.cs @@ -11,10 +11,12 @@ public class JRpcClient { private JRpcTransport Transport; private IDictionary> Requests; + private int? Timeout = null; - public JRpcClient(JRpcTransport transport) + public JRpcClient(JRpcTransport transport, int? timeout = null) { this.Transport = transport; + this.Timeout = timeout; this.Requests = new Dictionary>(); this.Transport.OnPacket += this.HandlePacket; @@ -87,9 +89,28 @@ public class JRpcClient var task = new TaskCompletionSource(); this.Requests.Add(id, task); - await this.Transport.Write(request.ToJsonString()); + _ = Task.Run(async () => + { + await this.Transport.Write(request.ToJsonString()); + }); - return await task.Task; + if (this.Timeout.HasValue) + { + if (await Task.WhenAny(task.Task, Task.Delay(this.Timeout.Value)) == task.Task) + { + return await task.Task; + } + else + { + this.Requests.Remove(id); + throw new JRpcException("Request Timeout"); + } + + } + else + { + return await task.Task; + } } public async Task SendRequest(string method, JsonArray param)