コード例 #1
0
        public void Init()
        {
            GrpcEnvironment.Initialize();

            server = new Server();
            server.AddServiceDefinition(MathGrpc.BindService(new MathServiceImpl()));
            int port = server.AddPort(host + ":0");

            server.Start();
            channel = new Channel(host + ":" + port);
            client  = MathGrpc.NewStub(channel);
        }
コード例 #2
0
ファイル: MathClientServerTests.cs プロジェクト: wfarr/grpc
        public void Init()
        {
            GrpcEnvironment.Initialize();

            server = new Server();
            server.AddServiceDefinition(MathGrpc.BindService(new MathServiceImpl()));
            int port = server.AddListeningPort(host + ":0");

            server.Start();
            channel = new Channel(host + ":" + port);

            // TODO: get rid of the custom header here once we have dedicated tests
            // for header support.
            var stubConfig = new StubConfiguration((headerBuilder) =>
            {
                headerBuilder.Add(new Metadata.MetadataEntry("customHeader", "abcdef"));
            });

            client = MathGrpc.NewStub(channel, stubConfig);
        }