Skip to content

Commit a88b70f

Browse files
author
Jacques Kang
committed
update readme
1 parent 64fa185 commit a88b70f

File tree

1 file changed

+17
-67
lines changed

1 file changed

+17
-67
lines changed

README.md

Lines changed: 17 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,25 @@ Support multi-threading on server side with configurable number of threads.
1515
2. Implement the service and host it in an console or web applciation
1616
3. Invoke the service with framework provided proxy client
1717

18-
## Sample:
18+
## Downloads
1919

20-
- Service contract
20+
IpcServiceFramework is available via NuGet:
21+
22+
- [JKang.IpcServiceFramework.Core](https://www.nuget.org/packages/JKang.IpcServiceFramework.Core/)
23+
- [JKang.IpcServiceFramework.Server](https://www.nuget.org/packages/JKang.IpcServiceFramework.Server/)
24+
- [JKang.IpcServiceFramework.Client](https://www.nuget.org/packages/JKang.IpcServiceFramework.Client/)
25+
26+
## Quick Start:
27+
28+
### Step 1 - Create service contract
2129
```csharp
2230
public interface IComputingService
2331
{
2432
float AddFloat(float x, float y);
2533
}
2634
```
2735

28-
- Service implementation
36+
### Step 2: Implement the service
2937

3038
```csharp
3139
class ComputingService : IComputingService
@@ -37,14 +45,7 @@ Support multi-threading on server side with configurable number of threads.
3745
}
3846
```
3947

40-
- Invoke the service from client process
41-
42-
```csharp
43-
var proxy = new IpcServiceClient<IComputingService>("pipeName");
44-
float result = await proxy.InvokeAsync(x => x.AddFloat(1.23f, 4.56f));
45-
```
46-
47-
- Host the service (Console application)
48+
### Step 3 - Host the service in Console application
4849

4950
```csharp
5051
class Program
@@ -71,64 +72,13 @@ Support multi-threading on server side with configurable number of threads.
7172
}
7273
}
7374
```
75+
It's possible to host IPC service in web application, please check out the sample project *IpcServiceSample.WebServer*
7476

75-
- Host the service (Web application)
76-
77-
```csharp
78-
public class Program
79-
{
80-
public static void Main(string[] args)
81-
{
82-
IWebHost webHost = BuildWebHost(args);
83-
84-
// run the IPC service host in a separated thread because it's blocking
85-
ThreadPool.QueueUserWorkItem(StartIpcService,
86-
webHost.Services.CreateScope().ServiceProvider);
87-
88-
webHost.Run();
89-
}
90-
91-
private static void StartIpcService(object state)
92-
{
93-
var serviceProvider = state as IServiceProvider;
94-
IpcServiceHostBuilder
95-
.Buid("pipeName", serviceProvider as IServiceProvider)
96-
.Run();
97-
}
98-
99-
public static IWebHost BuildWebHost(string[] args) =>
100-
WebHost.CreateDefaultBuilder(args)
101-
.UseStartup<Startup>()
102-
.Build();
103-
}
104-
```
105-
77+
### Step 4 - Invoke the service from client process
10678

10779
```csharp
108-
public class Startup
109-
{
110-
public void ConfigureServices(IServiceCollection services)
111-
{
112-
services
113-
.AddIpc(options =>
114-
{
115-
options.ThreadCount = 4;
116-
})
117-
.AddService<IComputingService, ComputingService>()
118-
;
119-
}
120-
121-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
122-
{
123-
app.Run(async (context) =>
124-
{
125-
await context.Response.WriteAsync("Hello World!");
126-
});
127-
}
128-
}
80+
var proxy = new IpcServiceClient<IComputingService>("pipeName");
81+
float result = await proxy.InvokeAsync(x => x.AddFloat(1.23f, 4.56f));
12982
```
13083

131-
I'll publish NuGet packages later.
132-
133-
Any contributions or comments are welcome!
134-
84+
__Please feel free to download, fork and/or provide any feedback!__

0 commit comments

Comments
 (0)