|
|
@@ -1,5 +1,7 @@ |
|
|
|
using Grpc.Core; |
|
|
|
using Grpc.Core.Interceptors; |
|
|
|
using JT808.DotNetty.Dashbord.GrpcServer.GrpcImpls; |
|
|
|
using JT808.DotNetty.Dashbord.GrpcServer.Interceptors; |
|
|
|
using JT808.GrpcDashbord.AtomicCounterGrpcService; |
|
|
|
using System; |
|
|
|
using System.Threading; |
|
|
@@ -14,7 +16,8 @@ namespace JT808.DotNetty.Dashbord.GrpcServer |
|
|
|
var server = new Server |
|
|
|
{ |
|
|
|
Services = { |
|
|
|
BindService(new JT808AtomicCounterServiceGrpcImpl()), |
|
|
|
BindService(new JT808AtomicCounterServiceGrpcImpl()) |
|
|
|
.Intercept(new DemoInterceptor()), |
|
|
|
}, |
|
|
|
Ports = { |
|
|
|
new ServerPort("0.0.0.0", 14000,ServerCredentials.Insecure) |
|
|
@@ -26,9 +29,11 @@ namespace JT808.DotNetty.Dashbord.GrpcServer |
|
|
|
Console.WriteLine(string.Format("RPC server {0} listening on port {1}", item.Host, item.Port)); |
|
|
|
} |
|
|
|
server.Start(); |
|
|
|
|
|
|
|
AtomicCounterServiceClient client = new AtomicCounterServiceClient(new Channel("127.0.0.1:14000", ChannelCredentials.Insecure)); |
|
|
|
var result=client.GetTcpAtomicCounter(new GrpcDashbord.ServiceGrpcBase.EmptyRequest()); |
|
|
|
Metadata metadata = new Metadata(); |
|
|
|
metadata.Add("token", "test"); |
|
|
|
metadata.Add("request", "web"); |
|
|
|
var result=client.GetTcpAtomicCounter(new GrpcDashbord.ServiceGrpcBase.EmptyRequest(), metadata); |
|
|
|
Console.ReadKey(); |
|
|
|
server.ShutdownAsync().Wait(); |
|
|
|
} |
|
|
|