Comments (4)
CommTarget是通讯目标,基本上就是ip+port, 还有两个超时参数。连接池什么的都在target里。
CommSession是一次req->resp的交互,主要要实现message_in(), message_out()等几个虚函数,让核心知道怎么产生消息。
CommService就是服务了,主要是new_session()的实现,因为对server来讲,session是被动产生的。
Communicator::request(CommSession *session, CommTarget *target)这个接口就可以实现一个异步的网络请求了,你可以写个程序试试,Session大概这么派生:
class MyHttpSession : public CommSession
{
private:
CommMessageOut *message_out() override { return new protocol::HttpRequest; }
CommMessageIn *message_in() override { return new protocol::HttpResponse; }
void handle(int state, int error) override
{
protocol::HttpResponse *resp = (protocol::HttpResponse *)this->get_message_in();
// print resp
...
delete this->get_message_out();
delete this->get_message_in();
delete this;
}
};
int main()
{
Communicator comm;
comm.init(2, 10);
CommTarget target;
target.init(...);
comm.request(new MyHttpSession, &target);
...
}
from workflow.
请问下CommConnection只有析构方法,为什么这么定义呢,出于什么考虑呢?
from workflow.
Target或Service里有个new_connection可以产生这个类的派生,用户可以给连接设置上下文。
from workflow.
Target或Service里有个new_connection可以产生这个类的派生,用户可以给连接设置上下文。
多谢
from workflow.
Related Issues (20)
- Turkish Character Support on get_parsed_body HOT 5
- Get All Headers of HTTP Request HOT 5
- http请求获取对方应答的数据接口是哪一个 HOT 1
- 能支持mqtt或zmq吗 HOT 1
- http server服务,使用WFGoTask处理请求结束后线程数没有降低 HOT 7
- 机器的连接达到了上限,如何关闭TIME_WAIT连接。 HOT 2
- 请教一个kafka 11错误码的问题 HOT 6
- workflow 如何支持 fast-dds? HOT 1
- http请求不响应问题 HOT 2
- 关于redis sub/pub问题 HOT 13
- workflow自定义协议如何分包发送消息 HOT 5
- 在使用kafka库组件时,突然出现 state=67, errorno= 5003 的错误 HOT 12
- workflow TCP服务端为什么发送数据时主动断开连接 HOT 21
- 在WFHttpServer的一个请求series里调用set_last_task设置一个任务不能成功返回http请求 HOT 5
- 怎样实现与MySQL原生客户端库libmysql相同的预编译相关接口(mysql_stmt_...)的功能 HOT 4
- workflow uds通讯的性能请教 HOT 7
- 在使用kafka库组件时,突然出现 state=67, errorno= 5003 的错误,这个问题重复出现了 HOT 21
- 关于使用kafka创建topic相关问题 HOT 2
- 请教关于任务流和任务调度的两个问题 HOT 17
- 关于tutorial-05-http_proxy的一些问题 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workflow.