├── .github
└── workflows
│ └── CI.yml
├── .gitignore
├── JsonRpcSharp.nuspec
├── JsonRpcSharp.sln
├── LICENSE.md
├── README.md
├── buildConf
└── Version.props
├── dir.props
├── lib
├── Newtonsoft.Json.dll
└── Readme.md
├── nblockchain.snk
└── src
├── AssemblyInfo.cs
├── AssemblyInfo.fs
├── JsonRpcSharp.Client
├── ClientBase.cs
├── Configuration.cs
├── DefaultJsonSerializerSettingsFactory.cs
├── IClient.cs
├── IRpcRequestHandler.cs
├── JsonRpcSharp.Client.csproj
├── RPCLogger.cs
├── RPCResponseException.cs
├── RequestInterceptor.cs
├── RpcClientTimeoutException.cs
├── RpcClientUnknownException.cs
├── RpcError.cs
├── RpcMessages
│ └── RpcMessages.cs
├── RpcRequest.cs
├── RpcRequestResponseHandler.cs
└── RpcRequestResponseHandlerNoParam.cs
├── JsonRpcSharp.HttpClient
├── HttpClient.cs
├── JsonRpcSharp.HttpClient.csproj
└── SimpleHttpClient.cs
├── JsonRpcSharp.IpcClient
├── IpcClient.cs
├── IpcClientBase.cs
├── JsonRpcSharp.IpcClient.csproj
├── JsonSerializerExtensions.cs
├── UnixDomainSocketEndPoint.cs
└── UnixIpcClient.cs
├── JsonRpcSharp.TcpClient
├── JsonRpcSharp.TcpClient.fsproj
└── TcpClient.fs
└── JsonRpcSharp.WebSocketClient
├── JsonRpcSharp.WebSocketClient.csproj
└── WebSocketClient.cs
/.github/workflows/CI.yml:
--------------------------------------------------------------------------------
1 | name: Build and deploy to NuGet
2 |
3 | on:
4 | push:
5 | pull_request:
6 | workflow_dispatch:
7 |
8 | # see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
9 | schedule:
10 | # daily
11 | - cron: "0 0 * * *"
12 |
13 | jobs:
14 | build_and_deploy:
15 | env:
16 | BASE_VERSION: 0.99.0
17 | runs-on: windows-latest
18 | steps:
19 | - uses: actions/checkout@v1
20 | - name: Build
21 | shell: cmd
22 | run: |
23 | dotnet build -p:Configuration=Release
24 | - name: Package and upload
25 | if: github.event_name == 'push' && github.ref == 'refs/heads/master'
26 | run: |
27 | git clone https://github.com/nblockchain/fsx
28 | fsx\Tools\fsi.bat fsx\Tools\nugetPush.fsx $env:BASE_VERSION ${{secrets.NUGET_API_KEY}}
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | #Backup
5 |
6 | Backup/
7 |
8 | # User-specific files
9 | *.suo
10 | *.user
11 | *.userosscache
12 | *.sln.docstates
13 |
14 | # User-specific files (MonoDevelop/Xamarin Studio)
15 | *.userprefs
16 |
17 | # Build results
18 | [Dd]ebug/
19 | [Dd]ebugPublic/
20 | [Rr]elease/
21 | [Rr]eleases/
22 | x64/
23 | x86/
24 | bld/
25 | [Bb]in/
26 | [Oo]bj/
27 | devChainRPCTests/
28 | testchain/clique/devChain/geth
29 | testchain/devChain/geth
30 | geth.exe
31 |
32 |
33 | # Visual Studio 2015 cache/options directory
34 | .vs/
35 | # Uncomment if you have tasks that create the project's static files in wwwroot
36 | #wwwroot/
37 |
38 | # MSTest test Results
39 | [Tt]est[Rr]esult*/
40 | [Bb]uild[Ll]og.*
41 |
42 | # NUNIT
43 | *.VisualState.xml
44 | TestResult.xml
45 |
46 | # Build Results of an ATL Project
47 | [Dd]ebugPS/
48 | [Rr]eleasePS/
49 | dlldata.c
50 |
51 | # DNX
52 | project.lock.json
53 | artifacts/
54 |
55 | *_i.c
56 | *_p.c
57 | *_i.h
58 | *.ilk
59 | *.meta
60 | *.obj
61 | *.pch
62 | *.pdb
63 | *.pgc
64 | *.pgd
65 | *.rsp
66 | *.sbr
67 | *.tlb
68 | *.tli
69 | *.tlh
70 | *.tmp
71 | *.tmp_proj
72 | *.log
73 | *.vspscc
74 | *.vssscc
75 | .builds
76 | *.pidb
77 | *.svclog
78 | *.scc
79 |
80 | # Chutzpah Test files
81 | _Chutzpah*
82 |
83 | # Visual C++ cache files
84 | ipch/
85 | *.aps
86 | *.ncb
87 | *.opensdf
88 | *.sdf
89 | *.cachefile
90 |
91 | # Visual Studio profiler
92 | *.psess
93 | *.vsp
94 | *.vspx
95 | *.sap
96 |
97 | # TFS 2012 Local Workspace
98 | $tf/
99 |
100 | # Guidance Automation Toolkit
101 | *.gpState
102 |
103 | # ReSharper is a .NET coding add-in
104 | _ReSharper*/
105 | *.[Rr]e[Ss]harper
106 | *.DotSettings.user
107 |
108 | # JustCode is a .NET coding add-in
109 | .JustCode
110 |
111 | # TeamCity is a build add-in
112 | _TeamCity*
113 |
114 | # DotCover is a Code Coverage Tool
115 | *.dotCover
116 |
117 | # NCrunch
118 | _NCrunch_*
119 | .*crunch*.local.xml
120 | nCrunchTemp_*
121 |
122 | # MightyMoose
123 | *.mm.*
124 | AutoTest.Net/
125 |
126 | # Web workbench (sass)
127 | .sass-cache/
128 |
129 | # Installshield output folder
130 | [Ee]xpress/
131 |
132 | # DocProject is a documentation generator add-in
133 | DocProject/buildhelp/
134 | DocProject/Help/*.HxT
135 | DocProject/Help/*.HxC
136 | DocProject/Help/*.hhc
137 | DocProject/Help/*.hhk
138 | DocProject/Help/*.hhp
139 | DocProject/Help/Html2
140 | DocProject/Help/html
141 |
142 | # Click-Once directory
143 | publish/
144 |
145 | # Publish Web Output
146 | *.[Pp]ublish.xml
147 | *.azurePubxml
148 | # TODO: Comment the next line if you want to checkin your web deploy settings
149 | # but database connection strings (with potential passwords) will be unencrypted
150 | *.pubxml
151 | *.publishproj
152 |
153 | # NuGet Packages
154 | *.nupkg
155 | # The packages folder can be ignored because of Package Restore
156 | **/packages/*
157 | # except build/, which is used as an MSBuild target.
158 | !**/packages/build/
159 | # Uncomment if necessary however generally it will be regenerated when needed
160 | #!**/packages/repositories.config
161 |
162 | # Windows Azure Build Output
163 | csx/
164 | *.build.csdef
165 |
166 | # Windows Azure Emulator
167 | efc/
168 | rfc/
169 |
170 | # Windows Store app package directory
171 | AppPackages/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | [Ss]tyle[Cc]op.*
182 | ~$*
183 | *~
184 | *.dbmdl
185 | *.dbproj.schemaview
186 | *.pfx
187 | *.publishsettings
188 | node_modules/
189 | orleans.codegen.cs
190 |
191 | # RIA/Silverlight projects
192 | Generated_Code/
193 |
194 | # Backup & report files from converting an old project file
195 | # to a newer Visual Studio version. Backup files are not needed,
196 | # because we have git ;-)
197 | _UpgradeReport_Files/
198 | Backup*/
199 | UpgradeLog*.XML
200 | UpgradeLog*.htm
201 |
202 | # SQL Server files
203 | *.mdf
204 | *.ldf
205 |
206 | # Business Intelligence projects
207 | *.rdl.data
208 | *.bim.layout
209 | *.bim_*.settings
210 |
211 | # Microsoft Fakes
212 | FakesAssemblies/
213 |
214 | # GhostDoc plugin setting file
215 | *.GhostDoc.xml
216 |
217 | # Node.js Tools for Visual Studio
218 | .ntvs_analysis.dat
219 |
220 | # Visual Studio 6 build log
221 | *.plg
222 |
223 | # Visual Studio 6 workspace options file
224 | *.opt
225 |
226 | # Visual Studio LightSwitch build output
227 | **/*.HTMLClient/GeneratedArtifacts
228 | **/*.DesktopClient/GeneratedArtifacts
229 | **/*.DesktopClient/ModelManifest.xml
230 | **/*.Server/GeneratedArtifacts
231 | **/*.Server/ModelManifest.xml
232 | _Pvt_Extensions
233 |
234 | # Paket dependency manager
235 | .paket/paket.exe
236 |
237 | # FAKE - F# Make
238 | .fake/
239 |
240 | # Windows image file caches
241 | Thumbs.db
242 | ehthumbs.db
243 |
244 | # Folder config file
245 | Desktop.ini
246 |
247 | # Recycle Bin used on file shares
248 |
249 | $RECYCLE.BIN/
250 |
251 | # Windows Installer files
252 | *.cab
253 | *.msi
254 | *.msm
255 | *.msp
256 |
257 | # Windows shortcuts
258 | *.lnk
259 |
260 | # =========================
261 | # Operating System Files
262 | # =========================
263 |
264 | # OSX
265 | # =========================
266 |
267 | .DS_Store
268 | .AppleDouble
269 | .LSOverride
270 |
271 | # Thumbnails
272 | ._*
273 |
274 | # Files that might appear on external disk
275 | .Spotlight-V100
276 | .Trashes
277 |
278 | # Directories potentially created on remote AFP share
279 | .AppleDB
280 | .AppleDesktop
281 | Network Trash Folder
282 | Temporary Items
283 | .apdisk
284 |
285 | # githubActions artifacts
286 | fsx
287 | nuget.exe
288 |
--------------------------------------------------------------------------------
/JsonRpcSharp.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | JsonRpcSharp
5 | 1.0.0
6 | JsonRpcSharp
7 | juanblanco, knocte
8 | knocte
9 | https://github.com/nblockchain/JsonRpcSharp/blob/master/LICENSE
10 | https://github.com/nblockchain/JsonRpcSharp
11 | https://github.com/nblockchain/JsonRpcSharp/blob/master/images/icon.png
12 | false
13 |
14 | JsonRpcSharp
15 |
16 |
17 | See: https://github.com/nblockchain/JsonRpcSharp/commits/master
18 |
19 | JsonRpcSharp
20 | JsonRpcSharp
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/JsonRpcSharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27130.2036
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{962EC435-6130-4B75-BAC1-12323B067443}"
7 | ProjectSection(SolutionItems) = preProject
8 | src\AssemblyInfo.cs = src\AssemblyInfo.cs
9 | src\AssemblyInfo.fs = src\AssemblyInfo.fs
10 | EndProjectSection
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonRpcSharp.Client", "src\JsonRpcSharp.Client\JsonRpcSharp.Client.csproj", "{84A6BAA7-32B3-4D99-9280-87023BFF0A5B}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonRpcSharp.IpcClient", "src\JsonRpcSharp.IpcClient\JsonRpcSharp.IpcClient.csproj", "{3D85110C-80C3-4136-A828-22CB066362A0}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonRpcSharp.HttpClient", "src\JsonRpcSharp.HttpClient\JsonRpcSharp.HttpClient.csproj", "{3F8D6B13-B483-4873-8946-106D25BF6212}"
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonRpcSharp.WebSocketClient", "src\JsonRpcSharp.WebSocketClient\JsonRpcSharp.WebSocketClient.csproj", "{82A720E5-CF5C-4963-86CE-BEEE3040B413}"
19 | EndProject
20 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "JsonRpcSharp.TcpClient", "src\JsonRpcSharp.TcpClient\JsonRpcSharp.TcpClient.fsproj", "{B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}"
21 | EndProject
22 | Global
23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
24 | Debug|Any CPU = Debug|Any CPU
25 | Debug|ARM = Debug|ARM
26 | Debug|x64 = Debug|x64
27 | Debug|x86 = Debug|x86
28 | Release|Any CPU = Release|Any CPU
29 | Release|ARM = Release|ARM
30 | Release|x64 = Release|x64
31 | Release|x86 = Release|x86
32 | EndGlobalSection
33 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
34 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Debug|ARM.ActiveCfg = Debug|Any CPU
37 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Debug|ARM.Build.0 = Debug|Any CPU
38 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Debug|x64.ActiveCfg = Debug|Any CPU
39 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Debug|x64.Build.0 = Debug|Any CPU
40 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Debug|x86.ActiveCfg = Debug|Any CPU
41 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Debug|x86.Build.0 = Debug|Any CPU
42 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Release|Any CPU.Build.0 = Release|Any CPU
44 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Release|ARM.ActiveCfg = Release|Any CPU
45 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Release|ARM.Build.0 = Release|Any CPU
46 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Release|x64.ActiveCfg = Release|Any CPU
47 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Release|x64.Build.0 = Release|Any CPU
48 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Release|x86.ActiveCfg = Release|Any CPU
49 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B}.Release|x86.Build.0 = Release|Any CPU
50 | {3D85110C-80C3-4136-A828-22CB066362A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51 | {3D85110C-80C3-4136-A828-22CB066362A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
52 | {3D85110C-80C3-4136-A828-22CB066362A0}.Debug|ARM.ActiveCfg = Debug|Any CPU
53 | {3D85110C-80C3-4136-A828-22CB066362A0}.Debug|ARM.Build.0 = Debug|Any CPU
54 | {3D85110C-80C3-4136-A828-22CB066362A0}.Debug|x64.ActiveCfg = Debug|Any CPU
55 | {3D85110C-80C3-4136-A828-22CB066362A0}.Debug|x64.Build.0 = Debug|Any CPU
56 | {3D85110C-80C3-4136-A828-22CB066362A0}.Debug|x86.ActiveCfg = Debug|Any CPU
57 | {3D85110C-80C3-4136-A828-22CB066362A0}.Debug|x86.Build.0 = Debug|Any CPU
58 | {3D85110C-80C3-4136-A828-22CB066362A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
59 | {3D85110C-80C3-4136-A828-22CB066362A0}.Release|Any CPU.Build.0 = Release|Any CPU
60 | {3D85110C-80C3-4136-A828-22CB066362A0}.Release|ARM.ActiveCfg = Release|Any CPU
61 | {3D85110C-80C3-4136-A828-22CB066362A0}.Release|ARM.Build.0 = Release|Any CPU
62 | {3D85110C-80C3-4136-A828-22CB066362A0}.Release|x64.ActiveCfg = Release|Any CPU
63 | {3D85110C-80C3-4136-A828-22CB066362A0}.Release|x64.Build.0 = Release|Any CPU
64 | {3D85110C-80C3-4136-A828-22CB066362A0}.Release|x86.ActiveCfg = Release|Any CPU
65 | {3D85110C-80C3-4136-A828-22CB066362A0}.Release|x86.Build.0 = Release|Any CPU
66 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
67 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Debug|Any CPU.Build.0 = Debug|Any CPU
68 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Debug|ARM.ActiveCfg = Debug|Any CPU
69 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Debug|ARM.Build.0 = Debug|Any CPU
70 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Debug|x64.ActiveCfg = Debug|Any CPU
71 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Debug|x64.Build.0 = Debug|Any CPU
72 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Debug|x86.ActiveCfg = Debug|Any CPU
73 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Debug|x86.Build.0 = Debug|Any CPU
74 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Release|Any CPU.ActiveCfg = Release|Any CPU
75 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Release|Any CPU.Build.0 = Release|Any CPU
76 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Release|ARM.ActiveCfg = Release|Any CPU
77 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Release|ARM.Build.0 = Release|Any CPU
78 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Release|x64.ActiveCfg = Release|Any CPU
79 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Release|x64.Build.0 = Release|Any CPU
80 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Release|x86.ActiveCfg = Release|Any CPU
81 | {3F8D6B13-B483-4873-8946-106D25BF6212}.Release|x86.Build.0 = Release|Any CPU
82 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
83 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Debug|Any CPU.Build.0 = Debug|Any CPU
84 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Debug|ARM.ActiveCfg = Debug|Any CPU
85 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Debug|ARM.Build.0 = Debug|Any CPU
86 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Debug|x64.ActiveCfg = Debug|Any CPU
87 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Debug|x64.Build.0 = Debug|Any CPU
88 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Debug|x86.ActiveCfg = Debug|Any CPU
89 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Debug|x86.Build.0 = Debug|Any CPU
90 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Release|Any CPU.ActiveCfg = Release|Any CPU
91 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Release|Any CPU.Build.0 = Release|Any CPU
92 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Release|ARM.ActiveCfg = Release|Any CPU
93 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Release|ARM.Build.0 = Release|Any CPU
94 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Release|x64.ActiveCfg = Release|Any CPU
95 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Release|x64.Build.0 = Release|Any CPU
96 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Release|x86.ActiveCfg = Release|Any CPU
97 | {82A720E5-CF5C-4963-86CE-BEEE3040B413}.Release|x86.Build.0 = Release|Any CPU
98 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
99 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
100 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Debug|ARM.ActiveCfg = Debug|Any CPU
101 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Debug|ARM.Build.0 = Debug|Any CPU
102 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Debug|x64.ActiveCfg = Debug|Any CPU
103 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Debug|x64.Build.0 = Debug|Any CPU
104 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Debug|x86.ActiveCfg = Debug|Any CPU
105 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Debug|x86.Build.0 = Debug|Any CPU
106 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
107 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Release|Any CPU.Build.0 = Release|Any CPU
108 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Release|ARM.ActiveCfg = Release|Any CPU
109 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Release|ARM.Build.0 = Release|Any CPU
110 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Release|x64.ActiveCfg = Release|Any CPU
111 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Release|x64.Build.0 = Release|Any CPU
112 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Release|x86.ActiveCfg = Release|Any CPU
113 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5}.Release|x86.Build.0 = Release|Any CPU
114 | EndGlobalSection
115 | GlobalSection(SolutionProperties) = preSolution
116 | HideSolutionNode = FALSE
117 | EndGlobalSection
118 | GlobalSection(NestedProjects) = preSolution
119 | {84A6BAA7-32B3-4D99-9280-87023BFF0A5B} = {962EC435-6130-4B75-BAC1-12323B067443}
120 | {3D85110C-80C3-4136-A828-22CB066362A0} = {962EC435-6130-4B75-BAC1-12323B067443}
121 | {3F8D6B13-B483-4873-8946-106D25BF6212} = {962EC435-6130-4B75-BAC1-12323B067443}
122 | {82A720E5-CF5C-4963-86CE-BEEE3040B413} = {962EC435-6130-4B75-BAC1-12323B067443}
123 | {B9DDEDCB-3A9F-4C9A-B222-E0F1F24222A5} = {962EC435-6130-4B75-BAC1-12323B067443}
124 | EndGlobalSection
125 | GlobalSection(ExtensibilityGlobals) = postSolution
126 | SolutionGuid = {07A44726-8749-4A9A-8079-FA3C3213BDC1}
127 | EndGlobalSection
128 | EndGlobal
129 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Nethereum.com (Juan Blanco) , Logo by Cass (https://github.com/cassiopaia)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or ANY portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | You can consume this library via nuget: https://www.nuget.org/packages/JsonRpcSharp
2 |
--------------------------------------------------------------------------------
/buildConf/Version.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | 0
4 | 1
5 | 0
6 | $(ReleaseSuffix)
7 |
8 |
9 | $(VersionMajor).$(VersionMinor).$(VersionPatch)-$(RelSuffix)
10 |
11 | $(FullNugetVersion)
12 | $(VersionMajor).$(VersionMinor).$(VersionPatch)
13 |
14 | $(NugetVersion)
15 |
16 |
17 |
--------------------------------------------------------------------------------
/dir.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lib/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nblockchain/JsonRpcSharp/d6738480b27802efffeddcaa44b4e6a1e289124a/lib/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/lib/Readme.md:
--------------------------------------------------------------------------------
1 | #External Libraries
2 | ## Newtonsoft.Json.dll
3 | This library is a modified version of Newtonsoft.Json.dll compatible with Unity3d
4 | For more information check https://github.com/SaladLab/Json.Net.Unity3D
5 |
--------------------------------------------------------------------------------
/nblockchain.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nblockchain/JsonRpcSharp/d6738480b27802efffeddcaa44b4e6a1e289124a/nblockchain.snk
--------------------------------------------------------------------------------
/src/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 |
2 | using System.Reflection;
3 |
4 | [assembly: AssemblyKeyFile("../../nblockchain.snk")]
5 |
--------------------------------------------------------------------------------
/src/AssemblyInfo.fs:
--------------------------------------------------------------------------------
1 | namespace JsonRpcSharp.TcpClient
2 |
3 | open System.Reflection
4 |
5 | []
6 |
7 | do
8 | ()
9 |
--------------------------------------------------------------------------------
/src/JsonRpcSharp.Client/ClientBase.cs:
--------------------------------------------------------------------------------
1 | #if !DOTNET35
2 | using System;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 | using JsonRpcSharp.Client.RpcMessages;
6 |
7 | namespace JsonRpcSharp.Client
8 | {
9 | public abstract class ClientBase : IClient
10 | {
11 |
12 | public TimeSpan ConnectionTimeout { get; set; } = TimeSpan.FromSeconds(20.0);
13 |
14 | public RequestInterceptor OverridingRequestInterceptor { get; set; }
15 |
16 | public async Task SendRequestAsync(RpcRequest request,
17 | string route = null,
18 | CancellationToken cancellationToken = default(CancellationToken))
19 | {
20 | if (OverridingRequestInterceptor != null)
21 | return
22 | (T)
23 | await OverridingRequestInterceptor.InterceptSendRequestAsync(SendInnerRequestAsync,
24 | request,
25 | route,
26 | cancellationToken)
27 | .ConfigureAwait(false);
28 | return await SendInnerRequestAsync(request, route, cancellationToken).ConfigureAwait(false);
29 | }
30 |
31 | public async Task SendRequestAsync(string method,
32 | string route = null,
33 | CancellationToken cancellationToken = default(CancellationToken),
34 | params object[] paramList)
35 | {
36 | if (OverridingRequestInterceptor != null)
37 | return
38 | (T)
39 | await OverridingRequestInterceptor.InterceptSendRequestAsync(SendInnerRequestAsync,
40 | method,
41 | route,
42 | cancellationToken,
43 | paramList).ConfigureAwait(false);
44 | return await SendInnerRequestAsync(method, route, cancellationToken, paramList).ConfigureAwait(false);
45 | }
46 |
47 | protected void HandleRpcError(RpcResponseMessage response)
48 | {
49 | if (response.HasError)
50 | throw new RpcResponseException(new RpcError(response.Error.Code, response.Error.Message,
51 | response.Error.Data));
52 | }
53 |
54 | private async Task SendInnerRequestAsync(RpcRequestMessage reqMsg,
55 | string route = null,
56 | CancellationToken cancellationToken = default(CancellationToken))
57 | {
58 | var response = await SendAsync(reqMsg, route, cancellationToken).ConfigureAwait(false);
59 | HandleRpcError(response);
60 | try
61 | {
62 | return response.GetResult();
63 | }
64 | catch (FormatException formatException)
65 | {
66 | throw new RpcResponseFormatException("Invalid format found in RPC response", formatException);
67 | }
68 | }
69 |
70 | protected virtual async Task SendInnerRequestAsync(RpcRequest request,
71 | string route = null,
72 | CancellationToken cancellationToken = default(CancellationToken))
73 | {
74 | var reqMsg = new RpcRequestMessage(request.Id,
75 | request.Method,
76 | request.RawParameters);
77 | return await SendInnerRequestAsync(reqMsg, route, cancellationToken).ConfigureAwait(false);
78 | }
79 |
80 | protected virtual async Task SendInnerRequestAsync(string method,
81 | string route = null,
82 | CancellationToken cancellationToken = default(CancellationToken),
83 | params object[] paramList)
84 | {
85 | var request = new RpcRequestMessage(Guid.NewGuid().ToString(), method, paramList);
86 | return await SendInnerRequestAsync(request, route, cancellationToken);
87 | }
88 |
89 | public virtual async Task SendRequestAsync(RpcRequest request,
90 | string route = null,
91 | CancellationToken cancellationToken = default(CancellationToken))
92 | {
93 | var response =
94 | await SendAsync(
95 | new RpcRequestMessage(request.Id, request.Method, request.RawParameters), route, cancellationToken)
96 | .ConfigureAwait(false);
97 | HandleRpcError(response);
98 | }
99 |
100 | protected abstract Task SendAsync(RpcRequestMessage rpcRequestMessage,
101 | string route = null,
102 | CancellationToken cancellationToken = default(CancellationToken));
103 |
104 | public virtual async Task SendRequestAsync(string method,
105 | string route = null,
106 | CancellationToken cancellationToken = default(CancellationToken),
107 | params object[] paramList)
108 | {
109 | var request = new RpcRequestMessage(Guid.NewGuid().ToString(), method, paramList);
110 | var response = await SendAsync(request, route, cancellationToken).ConfigureAwait(false);
111 | HandleRpcError(response);
112 | }
113 |
114 | protected CancellationToken GetEffectiveCancellationToken(CancellationToken providedToken, TimeSpan timeout)
115 | {
116 | if (providedToken == CancellationToken.None)
117 | {
118 | var cancellationTokenSource = new CancellationTokenSource();
119 | cancellationTokenSource.CancelAfter(timeout);
120 | return cancellationTokenSource.Token;
121 | }
122 | return providedToken;
123 | }
124 | }
125 | }
126 | #endif
--------------------------------------------------------------------------------
/src/JsonRpcSharp.Client/Configuration.cs:
--------------------------------------------------------------------------------
1 | namespace JsonRpcSharp.Client
2 | {
3 | public class Configuration
4 | {
5 | public static object DefaultRequestId { get; set; } = 1;
6 | }
7 | }
--------------------------------------------------------------------------------
/src/JsonRpcSharp.Client/DefaultJsonSerializerSettingsFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using Newtonsoft.Json;
6 | using Newtonsoft.Json.Serialization;
7 |
8 | namespace JsonRpcSharp.Client
9 | {
10 | public static class DefaultJsonSerializerSettingsFactory
11 | {
12 | public static JsonSerializerSettings BuildDefaultJsonSerializerSettings()
13 | {
14 | return new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore,
15 | MissingMemberHandling = MissingMemberHandling.Ignore };
16 | //ContractResolver = new NullParamsFirstElementResolver()}; Not required anymore.
17 | }
18 | }
19 | #if !DOTNET35
20 | //Passing a null value as the first parameter in the rpc (as no value) causes issues on client as it is not being ignored deserialising, as it is treated as the first element of the array.
21 | public class NullParamsFirstElementResolver : DefaultContractResolver
22 | {
23 | protected override IList CreateProperties(Type type, MemberSerialization memberSerialization)
24 | {
25 | return type.GetTypeInfo().DeclaredProperties
26 | .Select(p =>
27 | {
28 | var jp = CreateProperty(p, memberSerialization);
29 | jp.ValueProvider = new NullParamsValueProvider(p);
30 | return jp;
31 | }).ToList();
32 | }
33 | }
34 |
35 | public class NullParamsValueProvider : IValueProvider
36 | {
37 | private readonly PropertyInfo memberInfo;
38 |
39 | public NullParamsValueProvider(PropertyInfo memberInfo)
40 | {
41 | this.memberInfo = memberInfo;
42 | }
43 |
44 | public object GetValue(object target)
45 | {
46 | var result = memberInfo.GetValue(target);
47 | if (memberInfo.Name == "RawParameters")
48 | {
49 | var array = result as object[];
50 | if (array != null && array.Length == 1 && array[0] == null)
51 | result = "[]";
52 | }
53 | return result;
54 | }
55 |
56 | public void SetValue(object target, object value)
57 | {
58 | memberInfo.SetValue(target, value);
59 | }
60 | }
61 | #endif
62 | }
--------------------------------------------------------------------------------
/src/JsonRpcSharp.Client/IClient.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 |
4 | namespace JsonRpcSharp.Client
5 | {
6 | public interface IClient
7 | {
8 | #if !DOTNET35
9 | RequestInterceptor OverridingRequestInterceptor { get; set; }
10 | #endif
11 | Task SendRequestAsync(RpcRequest request,
12 | string route = null,
13 | CancellationToken cancellationToken = default(CancellationToken));
14 |
15 | Task SendRequestAsync(string method,
16 | string route = null,
17 | CancellationToken cancellationToken = default(CancellationToken),
18 | params object[] paramList);
19 |
20 | Task SendRequestAsync(RpcRequest request,
21 | string route = null,
22 | CancellationToken cancellationToken = default(CancellationToken));
23 |
24 | Task SendRequestAsync(string method,
25 | string route = null,
26 | CancellationToken cancellationToken = default(CancellationToken),
27 | params object[] paramList);
28 | }
29 | }
--------------------------------------------------------------------------------
/src/JsonRpcSharp.Client/IRpcRequestHandler.cs:
--------------------------------------------------------------------------------
1 | namespace JsonRpcSharp.Client
2 | {
3 | public interface IRpcRequestHandler
4 | {
5 | string MethodName { get; }
6 | IClient Client { get; }
7 | }
8 | }
--------------------------------------------------------------------------------
/src/JsonRpcSharp.Client/JsonRpcSharp.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | JsonRpcSharp.Client core library to use in conjunction with either the JsonRpcSharp.HttpClient, the JsonRpcSharp.IpcClient or other custom Rpc provider
4 | Juan Blanco
5 | JsonRpcSharp.Client
6 | $(JsonRpcSharpVersion)
7 | netstandard2.0
8 | JsonRpcSharp.Client
9 | JsonRpcSharp.Client
10 | Json;RPC
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | AssemblyInfo.cs
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/JsonRpcSharp.Client/RPCLogger.cs:
--------------------------------------------------------------------------------
1 | #if !DOTNET35
2 | using System;
3 | using Common.Logging;
4 | using JsonRpcSharp.Client.RpcMessages;
5 |
6 | namespace JsonRpcSharp.Client
7 | {
8 |
9 | public class RpcLogger
10 | {
11 | public RpcLogger(ILog log)
12 | {
13 | Log = log;
14 | }
15 | public ILog Log { get; private set; }
16 | public string RequestJsonMessage { get; private set; }
17 | public RpcResponseMessage ResponseMessage { get; private set; }
18 |
19 | public void LogRequest(string requestJsonMessage)
20 | {
21 | RequestJsonMessage = requestJsonMessage;
22 | if (IsLogTraceEnabled())
23 | {
24 | Log.Trace(GetRPCRequestLogMessage() );
25 | }
26 | }
27 |
28 | private string GetRPCRequestLogMessage()
29 | {
30 | return $"RPC Request: {RequestJsonMessage}";
31 | }
32 |
33 | private string GetRPCResponseLogMessage()
34 | {
35 | return ResponseMessage != null ? $"RPC Response: {ResponseMessage.Result}" : String.Empty;
36 | }
37 | private bool IsLogErrorEnabled()
38 | {
39 | return Log != null && Log.IsErrorEnabled;
40 | }
41 |
42 | public void LogResponse(RpcResponseMessage responseMessage)
43 | {
44 | if (responseMessage == null)
45 | throw new ArgumentNullException(nameof(responseMessage));
46 |
47 | ResponseMessage = responseMessage;
48 |
49 | if (IsLogTraceEnabled())
50 | {
51 | Log.Trace(GetRPCResponseLogMessage());
52 | }
53 |
54 | if (HasError(responseMessage) && IsLogErrorEnabled())
55 | {
56 | if (!IsLogTraceEnabled())
57 | {
58 | Log.Trace(GetRPCResponseLogMessage());
59 | }
60 | Log.Error($"RPC Response Error: {responseMessage.Error.Message}");
61 | }
62 | }
63 |
64 | public void LogException(Exception ex)
65 | {
66 | if (IsLogErrorEnabled())
67 | {
68 | Log.Error("RPC Exception, " + GetRPCRequestLogMessage() + GetRPCResponseLogMessage(), ex);
69 | }
70 | }
71 |
72 | private bool HasError(RpcResponseMessage message)
73 | {
74 | return message.Error != null && message.HasError;
75 | }
76 |
77 | private bool IsLogTraceEnabled()
78 | {
79 | return Log != null && Log.IsTraceEnabled;
80 | }
81 |
82 | }
83 |
84 | }
85 | #endif
--------------------------------------------------------------------------------
/src/JsonRpcSharp.Client/RPCResponseException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace JsonRpcSharp.Client
4 | {
5 | public class RpcResponseException : Exception
6 | {
7 | public RpcResponseException(RpcError rpcError) : base(rpcError.Message)
8 | {
9 | RpcError = rpcError;
10 | }
11 |
12 | public RpcError RpcError { get; }
13 | }
14 |
15 | public class RpcResponseFormatException : Exception
16 | {
17 | public RpcResponseFormatException(string message, FormatException innerException)
18 | : base(message, innerException)
19 | {
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/JsonRpcSharp.Client/RequestInterceptor.cs:
--------------------------------------------------------------------------------
1 | #if !DOTNET35
2 | using System;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 |
6 | namespace JsonRpcSharp.Client
7 | {
8 | public abstract class RequestInterceptor
9 | {
10 | public virtual async Task