本文整理汇总了C++中ChannelPtr::write方法的典型用法代码示例。如果您正苦于以下问题:C++ ChannelPtr::write方法的具体用法?C++ ChannelPtr::write怎么用?C++ ChannelPtr::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChannelPtr
的用法示例。
在下文中一共展示了ChannelPtr::write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test4GetStatus
void test4GetStatus(ChannelPtr& c)
{
const std::string jobHandle = "H:localhost.localdomain:4";
GearmanTaskPtr task(new GearmanTask);
task->request = GearmanMessage::createGetStatusMessage(jobHandle);
//writedown 往gearman写数据
c->write(UserEvent(task));
}
示例2: sendTo
sf::Error Datagram::sendTo (ChannelPtr channel) const {
if (channel->error()) return channel->error();
sf::ByteArrayPtr chunk = encode ();
if (!chunk) return error::TooMuch;
Error err = channel->write (chunk);
return err;
}
示例3: test4Echo
void test4Echo(ChannelPtr& c)
{
GearmanTaskPtr task(new GearmanTask);
ChannelBufferPtr buffer = Unpooled::buffer(1024, 64);
for (int i = 0; i < 20; ++i) {
buffer->writeByte('0');
}
task->request = GearmanMessage::createEchoReqMessage(buffer);
//writedown 往gearman写数据
c->write(UserEvent(task));
}
示例4: test4OptionReq
void test4OptionReq(ChannelPtr& c)
{
const std::string option = "exception";
GearmanTaskPtr task(new GearmanTask);
ChannelBufferPtr payload = Unpooled::buffer(1024, 64);
for (int i = 0; i < 10; ++i) {
payload->writeByte('0');
}
task->request = GearmanMessage::createOptionReqMessage(option);
//writedown 往gearman写数据
c->write(UserEvent(task));
}
示例5: test4submitJobHighBG
void test4submitJobHighBG(ChannelPtr& c)
{
const std::string functionName = "hello";
const std::string uniqueId = "123456";
GearmanTaskPtr task(new GearmanTask);
ChannelBufferPtr payload = Unpooled::buffer(1024, 64);
for (int i = 0; i < 10; ++i) {
payload->writeByte('0');
}
task->request = GearmanMessage::createsubmitJobHighBGMessage(functionName,uniqueId,payload);
//writedown 往gearman写数据
c->write(UserEvent(task));
}
示例6: main
/**
* A simple HTTP client that prints out the content of the HTTP response to
* {@link System#out} to test {@link HttpServer}.
*
* @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
* @author Andy Taylor ([email protected])
* @author <a href="http://gleamynode.net/">Trustin Lee</a>
*
* @version $Rev: 2226 $, $Date: 2010-03-31 11:26:51 +0900 (Wed, 31 Mar 2010) $
*/
int main(int argc, const char* argv[]) {
if (argc != 2) {
printf("Usage: SnoopClient <URL>");
return -1;
}
URI uri(argv[1]);
std::string scheme = uri.getScheme().empty() ? "http" : uri.getScheme();
std::string host = uri.getHost().empty() ? "localhost" : uri.getHost();
int port = uri.getPort();
if (port == -1) {
if (scheme == "http") {
port = 80;
}
else if (scheme == "https") {
port = 443;
}
}
if ((scheme != "http") && (scheme != "https")) {
printf("Only HTTP(S) is supported.");
return -1;
}
bool ssl = scheme == "https";
// Configure the client.
ClientBootstrap bootstrap(
ChannelFactoryPtr(new AsioClientSocketChannelFactory(1)));
// Set up the event pipeline factory.
bootstrap.setPipeline(getPipeline(ssl));
// Start the connection attempt.
ChannelFuturePtr future = bootstrap.connect(InetAddress(host, port));
// Wait until the connection attempt succeeds or fails.
ChannelPtr channel = future->awaitUninterruptibly()->channel();
if (!future->isSuccess()) {
bootstrap.shutdown();
return -1;
}
// Prepare the HTTP request.
HttpRequestPtr request =
HttpRequestPtr(new HttpRequest(HttpVersion::HTTP_1_1,
HttpMethod::GET,
uri.toString()));
request->setHeader(HttpHeaders::Names::HOST, host);
request->setHeader(HttpHeaders::Names::CONNECTION, HttpHeaders::Values::CLOSE);
request->setHeader(HttpHeaders::Names::ACCEPT_ENCODING, HttpHeaders::Values::GZIP);
// Set some example cookies.
//CookieEncoder httpCookieEncoder = new CookieEncoder(false);
//httpCookieEncoder.addCookie("my-cookie", "foo");
//httpCookieEncoder.addCookie("another-cookie", "bar");
//request->setHeader(HttpHeaders::Names::COOKIE, httpCookieEncoder.encode());
// Send the HTTP request.
channel->write(request);
// Wait for the server to close the connection.
channel->closeFuture()->awaitUninterruptibly();
// Shut down executor threads to exit.
bootstrap.shutdown();
return 0;
};