Skip to content

Commit

Permalink
Updated readme.md with better sample info.
Browse files Browse the repository at this point in the history
  • Loading branch information
Troy Willmot committed Oct 8, 2016
1 parent 23ed9f1 commit 580af5b
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ Short description: A Json RPC 2.0 client library for .Net.

Long Description: Spooky is two things;

1. A portable, async-await based, .Net abstraction for RPC clients
1. A portable, async-await based, .Net abstraction for RPC clients.
2. An implementation of the Json RPC 2.0 specification over HTTP (using HttpClient) fitting that abstraction.

Basically Spooky lets you make Json RPC calls, and could theoretically be extended to work with XML-RPC, future Json RPC versions and other similar systems without altering dependant systems.
Because the Json RPC implementation uses HttpClient for transport, it supports injecting message handlers into the HTTP pipeline. This allows support for HTTP based authentication/authorisation, compression, retry logic etc.
(assuming the server is also compatible with those features)
(assuming the server is also compatible with those features).

The transport, serialization and client layers are all separate, so while Json RPC over HTTP is supported out of the box, implementing it over sockets or another network protocol should be relatively simple and self-contained.
By relying on the abstraction, clients are protected from changing requirements at the network or serialization layers, and could even choose those at runtime.

[![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/Yortw/Spooky/blob/master/LICENSE.md)

Expand All @@ -29,17 +32,41 @@ Currently;
## How do I use Spooky?
*We got your samples right here*

Install the relevant Nuget package. If you want to do Json RPC (2.0) do this;
Install the relevant Nuget package.

If you just want the abstraction layer to write your own implementation against, try;
```powershell
PM> Install-Package Spooky.Json20
PM> Install-Package Spooky
```

If you just want the abstraction layer to write your own implementation against, try
If you want to do Json RPC (2.0) do this;
```powershell
PM> Install-Package Spooky
PM> Install-Package Spooky.Json20
```

[![NuGet Badge](https://buildstats.info/nuget/Spooky)](https://www.nuget.org/packages/Spooky/)
Once the package is installed, add a using for the Spooky.Json20 namespace;
```c#
using Spooky.Json20;
```

Then create an client and call the *Invoke method* to start making remote calls. The following sample calls a remote *add* procedure passing two arguments by name, *a* and *b*. Both named and
positional arguments are supported. For positional arguments use an object array or the overload that takes params object[]. For named arguments pass a dictionary as shown in this sample.
```c#
var client = new Spooky.Json20.JsonRpcHttpClient(new Uri("http://www.myserver.com/mathservice"));
var answer = await client.Invoke<int>
(
"add",
new Dictionary<string, object>()
{
{ "a", 4 },
{ "b", 6 }
}
).ConfigureAwait(false);
```

That's it, you've made your first successful RPC call!

[![NuGet Badge](https://buildstats.info/nuget/Spooky)](https://www.nuget.org/packages/Spooky/)

## Server Implementation
Spooky doesn't even attempt to provide a server implementation. If you want to implement a server in .Net, try the awesome [Jayrock](https://github.com/atifaziz/Jayrock) library.

0 comments on commit 580af5b

Please sign in to comment.