本文整理汇总了C++中ChannelPtr::setInitializer方法的典型用法代码示例。如果您正苦于以下问题:C++ ChannelPtr::setInitializer方法的具体用法?C++ ChannelPtr::setInitializer怎么用?C++ ChannelPtr::setInitializer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChannelPtr
的用法示例。
在下文中一共展示了ChannelPtr::setInitializer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connect
ChannelFuturePtr ClientBootstrap::connect(const InetAddress& remote,
const InetAddress& local) {
if (!remote) {
LOG_INFO << "the remote address is invalidated, then return a failed future.";
return NullChannel::instance()->newFailedFuture(
ChannelException("Failed to initialize a pipeline."));
}
ChannelPtr ch = newChannel();
if (!ch) {
LOG_INFO << "failed to create a new channel, then return a failed future.";
return NullChannel::instance()->newFailedFuture(
ChannelException("Failed to create a new channel."));
}
if (!initializer()) {
LOG_INFO << "has not set channel pipeline initializer.";
return NullChannel::instance()->newFailedFuture(
ChannelException("has not set channel pipeline initializer."));
}
ch->setInitializer(initializer());
ch->open();
ch->closeFuture()->addListener(boost::bind(
&ClientBootstrap::closeChannelBeforeDestruct,
this,
_1,
ch));
// Set the options.
ch->config().setOptions(options());
insertChannel(ch->id(), ch);
// Bind.
if (localAddress()) {
LOG_INFO << "bind the channel to local address" << local.toString();
ChannelFuturePtr future = ch->bind(local);
future->awaitUninterruptibly();
}
// ch->closeFuture()->addListener(
// boost::bind(&ClientBootstrap::onChannelClosed,
// this,
// _1));
// Connect.
return ch->connect(remote);
}