コード例 #1
0
ファイル: channel_create.c プロジェクト: wuyunhao/grpc
static grpc_subchannel *client_channel_factory_create_subchannel(
    grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory,
    grpc_subchannel_args *args) {
  client_channel_factory *f = (client_channel_factory *)cc_factory;
  connector *c = gpr_malloc(sizeof(*c));
  grpc_channel_args *final_args =
      grpc_channel_args_merge(args->args, f->merge_args);
  grpc_subchannel *s;
  memset(c, 0, sizeof(*c));
  c->base.vtable = &connector_vtable;
  gpr_ref_init(&c->refs, 1);
  c->handshake_mgr = grpc_handshake_manager_create();
  char *proxy_name = grpc_get_http_proxy_server();
  if (proxy_name != NULL) {
    grpc_handshake_manager_add(
        c->handshake_mgr,
        grpc_http_connect_handshaker_create(proxy_name, args->server_name));
    gpr_free(proxy_name);
  }
  args->args = final_args;
  s = grpc_subchannel_create(exec_ctx, &c->base, args);
  grpc_connector_unref(exec_ctx, &c->base);
  grpc_channel_args_destroy(final_args);
  return s;
}
コード例 #2
0
ファイル: chttp2_connector.c プロジェクト: izouxv/grpc
static void start_handshake_locked(grpc_exec_ctx *exec_ctx,
                                   chttp2_connector *c) {
  c->handshake_mgr = grpc_handshake_manager_create();
  char *proxy_name = grpc_get_http_proxy_server();
  if (proxy_name != NULL) {
    grpc_handshake_manager_add(c->handshake_mgr,
                               grpc_http_connect_handshaker_create(proxy_name));
    gpr_free(proxy_name);
  }
  if (c->add_handshakers != NULL) {
    c->add_handshakers(exec_ctx, c->add_handshakers_user_data,
                       c->handshake_mgr);
  }
  grpc_handshake_manager_do_handshake(
      exec_ctx, c->handshake_mgr, c->endpoint, c->args.channel_args,
      c->args.deadline, NULL /* acceptor */, on_handshake_done, c);
  c->endpoint = NULL;  // Endpoint handed off to handshake manager.
}
コード例 #3
0
static void handshaker_factory_add_handshakers(
    grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* factory,
    const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
  grpc_handshake_manager_add(handshake_mgr,
                             grpc_http_connect_handshaker_create());
}